Question

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.

Was it helpful?

Solution 2

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

OTHER TIPS

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).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top