N.avraham
N.avraham

Reputation: 343

How can a c++ exe locate a c# dll?

I am trying to run a c++ application that uses a c# dll. I created a clr wrapper class so that the c++ exe can load the c# dll. When I run the exe from the same directory where the c# dll is located, the application runs fine.

But, what I would like to do is to put all my application's dlls in another directory. so my question is:

How can I put the c# dll in a different directory from where my c++ app is located, and enable the exe to load that dll?

I believe there is an option to use a configuration file, but I do not understand how exactly this is done.

Can anyone explain the way it can be achieved?

Upvotes: 0

Views: 69

Answers (1)

Dmitry Egorov
Dmitry Egorov

Reputation: 9650

If the dll's directory is a subdirectory of the executable, you may use <probing> element of your app.config:

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

Upvotes: 1

Related Questions