AnsweredAssumed Answered

How to prevent AddIn from loading referenced assemblies from SolidWorks base dir

Question asked by Alexander Schaaf on May 8, 2017
Latest reply on Aug 13, 2020 by Alexander Schaaf

Hello, I have written a SolidWorks AddIn with the default Template and I have several questions:


Visual Studio is throwing the following error :

Managed Debugging Assistant 'LoadFromContext' has detected a problem in 'C:\Program Files\SolidWorksCorp2014\SolidWorks\SLDWORKS.exe'.

Additional information: The assembly named 'myAssembly' was loaded from 'PathToMyAssembly' using the LoadFrom context.

The use of this context can result in unexpected behavior for serialization, casting and dependency resolution. In almost all cases, it is recommended that the LoadFrom context be avoided. This can be done by installing assemblies in the Global Assembly Cache or in the ApplicationBase directory and using Assembly.Load when explicitly loading assemblies.


Actually I always ignored this error and never have had any problems, but now I ran into another Issue. I have a WPF Window that is using When I now reference the DLL, inside VS everything is fine. But once I want to show the window, it's throwing a "File not found Exception". Funny thing, when I insert the following line before the InitializeComponent call of my WPF window, the error goes away:

Dim test As Reflection.Assembly = Reflection.Assembly.LoadFrom("D:\VisualStudio\Projects\xxx\Build\System.Windows.Interactivity.dll")

I Think this happens because SolidWorks has an older version of System.Windows.Interactivity.dll inside the application base directory.


Can anyone help me to get away this messy references? I am googling now for some days and come close to surrender.


Thanks in advance,