- For individual users
- Instant access to solutions
- Ask your tech questions
- Start your 30-day Free Trial
Main Topics
Browse All TopicsI have Window's forms application that calls a DLL. If the DLL is in the same directory as the application it works great. If the DLL is in a different directory, the application gets an unhandled exception that the assembly could not be loaded. According to the documentation on Microsoft's site "Window searches ... The directory where the executable module for the current process is located....[it then searches]... The directories listed in the PATH environment variable. I have put the DLL in a directory that is in the PATH variable but it is not found. This is on a Windows 2003 server. Any ideas?
This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.
Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.
If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.
Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.
Access the answers to your technology questions today.
30-day free trial. Register in 60 seconds.
Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Try it out and discover for yourself.
30-day free trial. Register in 60 seconds.
Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.
Business Accounts
Answer for Membership
by: ororiolePosted on 2008-07-30 at 17:12:31ID: 22126002
It sounds like you were reading WINDOWS (as in the OS) documentation, not .NET CLR documentation. The CLR never checks the PATH variable. What are you kidding me? THAT would be too simple.
en-us/libr ary/15hyw9 x3(VS.80). aspx
No, I really like .NET, I just threw that last bit in. heh.
Anyway, its true about PATH, the CLR uses its own technique. I'll give you a link, but first I'll make it simpler. For most cases, the msdn doc on this is way too complicated. The simple version is:
First, it looks in the GAC.
Second, (the rest of the process is called "probing"), in looks in your config file for a <codebase> element that specifies the path(s). If there is a codebase, but it doesnt find the assembly, it stops.
Third, if no codebase element, then it looks in the application root directory.
Fourth. It looks for subdirectories under the root with the same name as the assembly. If you have a subdirectory call MyTest then it will look in there for MyTest.dll
Fifth. It looks for a <probing> element in your config file and tries that path, which also has to be under the root.
After that it trys a couple of other things but mostly you are out of luck.
Now, in your case it sounds like you want the .dll outside of the root directory. You are limited to the first two steps: The GAC, and specifying where it is via the <codebase> element. In either case, you MUST strongname the assembly for steps one or two to work.
And now ya know.
http://msdn.microsoft.com/