-1

I have a vsto outlook that references my library my.dll. This dll reference a 3rd party dummy.dll in C:\Programs Files\company\dummy.dll

The objectif is if dummy.dll is changed, it will be independent with my.dll

In the project of my.dll:

If I set copy local to true, the dummy.dll is copied to the bin, that doesn’t like I expected because my.dll doesn’t know about the newer version of dummy

If I set copy local to false, an exception comes because file not found.

I found this article of Microsoft and others posts in SO, they talks about GAC, .config or AssemblyResolvebut I think it’s not like my situation because it’s a vsto.

How can I use dummy.dll in c:\program files without copying it?

Antoine V
  • 6,998
  • 2
  • 11
  • 34

2 Answers2

0

If the DLL is in a subdirectory of your application, you can tell .NET to bind to it using the probing path portion of the application's configuration.

If the DLL is in a directory that is not a subdirectory of your application, you will have to put it in the global assembly cache. This is not usually recommended.

The simplest approach though is to copy the file. That is how this sort of thing is commonly handled. Before .NET, DLLs could be anywhere, but that sort of arrangement often resulted in what was called DLL Hell. Having a private copy of the DLL eases many deployment concerns and the disk space usage should not be an issue.

John Wu
  • 50,556
  • 8
  • 44
  • 80
  • After thinking about your answer and some research, I think copy file is correct. I make some tests and tell you later – Antoine V Jan 25 '19 at 09:22
0

Your best bet would be to use the exe.config option from that article. We do this all of the time to reference third party application dlls that are in that party's directories.

<configuration>
   <runtime>
      <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
         <dependentAssembly>
            <assemblyIdentity name="MyAssembly2" publicKeyToken="307041694a995978"/>
            <codeBase version="1.0.1524.23149" href="C:\Myassemblies\MyAssembly2.dll"/>
         </dependentAssembly>
      </assemblyBinding>
   </runtime>
</configuration>
Mikanikal
  • 1,082
  • 8
  • 12