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.
Asked
Active
Viewed 618 times
2
-
are you loading it through reflection? – Furqan Hameedi Jul 10 '12 at 11:04
-
1Try http://stackoverflow.com/questions/1087794/c-sharp-load-a-dll-file-and-access-methods-from-class-within – Ivan Golović Jul 10 '12 at 11:05
-
What error are you getting? Are you sure it's because of the folders? – joocer Jul 10 '12 at 12:58
1 Answers
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