How does a .NET console application look for referenced assemblies?
c#, console, dll
Solution
The simplest answer is to put the DLL's in the same directory as the Console Application and it will find them.
The longer answer is fairly complex as there are many factors which influence how and where the CLR looks for referenced assemblies. I encourage you to take a look at the following article from MSDN which goes into great detail as to how this works.
- http://msdn.microsoft.com/en-us/magazine/cc164080.aspx
Problem
I created a console application using C# that references external DLLs. When I run it on my dev machine, everything works fine. On the production machine, I get a "type initiatization" error. Looking into this, it seems it may because the app can't find the referenced DLLs. On my dev box, the referenced DLLs are in the GAC, but not on the production one. When removing the DLLs from the GAC on the dev box, the same error occurs (unless I run it from a local Visual Studio build in debug mode). I'm more familiar with web site setups, and know there that the DLLs can be placed in the bin directory or the GAC so they can be found by the web application. But I'm not sure about how this works for console apps. I'm reluctant to put the DLL into the GAC on the production box, as it's only needed for this one small application. Are there other ways for me to deploy the console app and have it find its required assemblies? Here is the exception I'm getting: Error 1 The type or namespace name 'Entry' could not be found (are you missing a using directive or an assembly reference?) C:\Documents and Settings\Hacker\My Documents\Visual Studio 2005\Projects\basic\basic\Program.cs 10 8 basic