I don’t have specific code to test this but I would like to create a zero touch that would work on both previous versions of Dynamo and new ones, identifying .NET and so on… does anyone have an example of how I could do this with the same code or something like that?
Hey,
If you have a look on github, you can see how different package authors manage this. Archilab has a set of nodes per version and targets the appropriate .net framework, determined at runtime (I believe!)…
namespace test.example
{
public class SampleClass
{
public static string GetSampleInfo()
{
Document doc = DocumentManager.Instance.CurrentDBDocument;
string version = doc.Application.VersionNumber;
if (int.TryParse(version, out int versionNumber))
{
if (versionNumber < 2021)
{
return RunForOlderVersions(doc);
}
else
{
return RunForNewerVersions(doc);
}
}
return "Unknown version.";
}
private static string RunForOlderVersions(Document doc)
{
#if NET48
// Implementation for .NET Framework 4.8 and versions earlier than 2021
return "Running with .NET Framework 4.8 for versions earlier than 2021.";
#endif
}
private static string RunForNewerVersions(Document doc)
{
#if NET6_0_WINDOWS
// Implementation for .NET 6.0 and versions 2021 or later
return "Running with .NET 6.0 for versions 2021 or later.";
#endif
}
}
}
Hope that is useful,
Mark
Unfortunately, this won’t work if he referenced a dlls directly as it simply won’t load. I do believe konrad builds his package for each version, but that’s why his install process is a bit different, where users have to pay attention to the version number.