2

My c# application is loading a C# dll. This c# dll loads a c dll through DllImport. I want that both of these dlls are present in other folder then that of the current working directory. But I dont want to modify it environment variable. I tried SetDllDirectory but unable to load these dlls. Do you have any idea how i can do it.

Rohit Garg
  • 101
  • 1
  • 2
  • 5

1 Answers1

0

Try adding this to Your config file:

    <?xml version="1.0"?>
    <configuration>
      <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
          <probing privatePath="FolderName;OtherFolderName"/>
        </assemblyBinding>
      </runtime>
    </configuration>

Those folders need to be subdirectories of your app directory.

Grzegorz W
  • 3,487
  • 1
  • 21
  • 21
  • I am able to load c# dll by specifying path in LoadFrom but not able to load C dll(Loaded by C# Dll). If i try LoadLibrary in the application i am able to load C# and C dll both so SetDll directory is working fine. If i place all the dlls in current folder then application runs fine. the probing tag only loads the C# dll but unable to load its dependencies from other folder. In this case it is C dll. – Rohit Garg Jul 11 '12 at 04:32