embedded dependencies can not be resolved when the Assembly is loaded dynamically

We use SmartAssembly to embed referenced assemblies into a main assembly, so that we only have to deploy this one single main assembly.

Example:

Assembly ABC.dll and Assembly DEF.dll are referenced by the main.dll. That we only have to deploy one main.dll we add ABC.dll and DEF.dll as embedded ressources to one single main.dll with SmartAssembly.

When the resulting main assembly is added into a .Net-project statically everything works fine.
But when the main assembly is loaded dynamically into a customer application (like calling our main.dll from Matlab) the embeded assemblies ABC.dll and DEF.dll can not be resolved anymore.

Following code in a customer application:
Assembly mainAssembly = Assembly.LoadFile("PathToMainAssembly\main.dll");
Type mainClassType = mainAssembly.GetType("main.mainClass");
ConstructorInfo mainClassConstructorInfo = mainClassType .GetConstructor(new Type[] { });
object mainClass= mainClassConstructorInfo?.Invoke(null);

Leads to a System.Exception {System.Reflection.TargetInvocationException because the assembly ABC.dll can not be resolved.

Question:
SmartAssembly states the following

So my understanding is when the main assembly is loaded, then all dependecies should be available for the application domain. But that does not happen.
So what am I missing or missunderstanding?
Is there a simple option i did not check in SmartAssembly?
Is this a generall problem with SmartAssemblies when a combined Assembly is loaded dynamically?
Does anyone knwos a workaround?

Any help would be highly appreciated.
Tagged:

Answers

  • buejbuej Posts: 2 New member
    SmartAssembly works fine. The problem was in the load method of the customer application (Matlab).
    The Matlab-method Net.addassembly has problems by resolving the embedde dependecies.
    As a workaround i used the .Net - reflection methods in a Matlab-script and not the Matlab-method.
    Therefore the problem is "solved".
  • Jessica RJessica R Posts: 1,319 Rose Gold 4
    Glad to hear that @bluej, thanks for the update!

    Jessica Ramos | Product Support Engineer | Redgate Software

    Have you visited our Help Center?


Sign In or Register to comment.