How can I load any .NET class from a RevitAPI external command? I'm constantly getting this error even after adding a reference to the .dll file in the .csproj file: "Could not load "System.Globalization" from "System.Runtime" assembly" version 4.0.0.0"".
Solved! Go to Solution.
Solved by jeremy_tammik. Go to Solution.
Yes, a Revit add-in can make use of all the standard .NET library assembly DLLs.
You must be doing something special to cause a problem like that.
Obviously I cannot guess what you might be doing wrong.
If in doubt, I would recommend throwing away all your problematic stuff for the time being and starting from scratch.
Normally, the problem should immediately disappear.
Then you can add back you problematic components piece by piece until the problem reappears.
That might help you sort out what is causing it.
Good luck sorting it out.
Thanks for the response. I was coding and compiling my class library from .NET CLI. Therefore the .CSPROJ file lacks many of the components that a default Visual Studio .CSPROJ automatically generated file brings. I would like to continue learning to create external commands and external applications in .NET CLI, but this entails knowledge of MSBUILD and other elements. But so far, I can reach .NET dlls trough the default class library project that Visual Studio generates. Thank you!
Thanks also for your response Gary.
I'm publishing my external command through .NET CLI with "win-x64" as the runtime option, and .NET6.0 as the framework option.
But when I browse to the location of the dlls in my computer, I find that they are located on this folder: "C:\Windows\Microsoft.NET\Framework64\v4.0.30319".
I don't know if this is the "4.0.0.0" version
that the error message displays.
I believe that the installed .NET assemblies (for development and what should be referenced and/or included) are found here:
Of course, all of this could just be because I'm using Visual Studio and these may just be installed and referenced by default because of that, but I believe that this is also the structure that is created if you install a given version of the .NET libraries from Microsoft.
-G
string location = Assembly.GetExecutingAssembly().Location;
DirectoryInfo directory = new DirectoryInfo(location);
var pathTmp = directory.Parent.FullName + "\\Microsoft.Xaml.Behaviors.dll";
if (File.Exists(pathTmp))
{
Assembly.LoadFrom(pathTmp);
}
Change the dll name to yours, at the start of execution.
I have met same question, dll is not load automatically.
Don't know why.
Can't find what you're looking for? Ask the community or share your knowledge.