I have a .Net application which uses a couple of .Net dll's, these dll's are located in a folder which is included in the PATH environment variable, but when I start my .Net App if fails with the error:
Could not load file or assembly 'FxDoc.dll, Version=1.2.10.0, Culture=neutral, PublicKeyToken=1b44e1d4261664821' or one of its dependencies. The system cannot find the file specified.
I already have read these MSDN entries Search Path Used by Windows to Locate a DLL
and Dynamic-Link Library Search Order
Which states:
Windows then searches for the DLLs in the following sequence:
The directory where the executable module for the current process is located.
The current directory.
The Windows system directory. The GetSystemDirectory function retrieves the path of this directory.
The Windows directory. The GetWindowsDirectory function retrieves the path of this directory.
The directories listed in the PATH environment variable.
My questions are:
The rules for .NET assemblies and plain-old DLLs are not the same. The rules you listed are for plain-old DLLs.
Assembly loading is surprisingly complicated, but the basic search order is like this:
The environment variable PATH isn't used for .NET assemblies. For all the gruesome details, you'll probably want to look at the official documentation:
http://msdn.microsoft.com/en-us/library/aa720133.aspx
Most places I've worked, people stick to the basics -- either the assembly goes into the GAC, or it's placed in the same directory as the application.
You might also be interested in this tool (fuslogvw.exe) which helps you figure out why the loader isn't finding your assembly:
http://msdn.microsoft.com/en-us/library/e74a18c4.aspx
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With