daregazi
daregazi

Reputation: 65

VB6 failing to consume a C# library which dynamically loads assembly from byte array

I have a c# library which loads a plugin assembly using the Assembly.Load(byte[]) method. The plugin has to be loaded from its bytes array rather than a path. The library and plugin and all its dependencies are loaded correctly when the consuming app is a .Net app. However this fails when the consumer is a VB6 app. I get DllNotFoundException exception in loading some of the plugins dependencies/dlls. How can I fix this?

Upvotes: 0

Views: 50

Answers (1)

daregazi
daregazi

Reputation: 65

An update on this for future references... In the wrapper library for COM use, we subscribed to the AssemblyResolve event which is raised when a dependent .Net assembly could not be found, this event would contain the assembly name, so we handled the event correctly. Also in our COM wrapper library, we did a DllImport("kernel32.dll") to overwrite the SetDllDirectory and append extra search path to be able to find native dependent assemblies.

These 2 solved the problem.

Upvotes: 1

Related Questions