1

OK, here is the setup:

  • A VB6 .exe that consumes some .Net classes.
  • The classes reside in 5 .dll's but are exposed through one COM visible wrapper .dll
  • Using an application manifest I can store the COM visible MyCOMVisibleWrapper.dll (and .tlb) wrapper in a subfolder named MyCOMVisibleWrapper.
  • I would like to store the dependent .Net .dlls in that folder too.
  • However the CLR looks for these .dll's in the folder where the VB6 executable resides, not in the folder where the wrapper .dll lives.

How can I add the MyCOMVisibleWrapper folder to the resolution path? I tried including a MyCOMVisibleWrapper.dll.config file with a <probing privatePath=MyComVisibleWrapper/> tag, but that doesn't work. I read about implementing the AssemblyResolve EventHandler but I am unsure about where to put that, as the .Net code has no main entry point.

Dabblernl
  • 15,831
  • 18
  • 96
  • 148

2 Answers2

0

If your wrapper DLL is getting correctly located then you can handle the Assembly resolve there. Or you can explicitly use LoadFrom to load those Assemblies from the path you'd like. (You do need to use some care with LoadFrom, as some use-cases involving multiple places to find those Assemblies can cause errors).

tcarvin
  • 10,715
  • 3
  • 31
  • 52
  • Thanks for your reply. The problem is that the wrapper .dll has no main entry point, it is just a bunch of interfaces and classes that implement the interfaces and inherit the native CLR classes to do some marhsalling of the parameters. – Dabblernl Nov 09 '11 at 13:34
  • Perhpas you can use a static constructor to ensure that your code runs. If there is no central class that you are assured of being loaded, I suppose you could add a cookie cutter static constructor to each public class, which in turn reference a singleton static class to kicj its static constructor. In that singleton you can put your AssemblyResolve code. – tcarvin Nov 09 '11 at 14:53
0

You have to make a config file named MyVB6App.exe.config that has the following content:

    <configuration> 
     <runtime>
       <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
          <probing privatePath="MyCOMVisibleWrapper"/>
       </assemblyBinding>
     </runtime>
   </configuration>

Now you can put the whole shebang, apart from the MyVB6App.exe.Manifest in the MyComVisibleWrapper folder.

Look here for a more extensive discussion

Dabblernl
  • 15,831
  • 18
  • 96
  • 148