Reputation: 1075
I have a situation where I need to add a *.dll project (Class library say, ClassLib.dll) to the Start Up project (Containing the .exe). But I am facing a problem here. First I need to compile the library project, and add that dll reference to the main solution through reference -> Add reference then add the ClassLib.dll after browsing the path bin -> debug path.
But my first question is question is in which build shall I add the dll? If I add the release build dll, then the release build path (Bin -> Release -> ClassLib.dll) is different than debug build (Bin -> Debug -> ClassLib.dll).
Now if i need to debug the source code of the class library as well as my exe project, then surely I need to reference the debug mode dll.
But any changes I do in the class library project I need to compile that in release build, so that startup project along with class library project we can build and release for final build.
If I refer to the Release mode dll and I do Clean solution is release mode, then I start debug mode, then I get an error "FileNotFoundException". Which is ofcourse that the dll file is missing from Release path which was a reference.
I have seen few projects having separate ClassLib.dll in Debug mode and release mode compilation. How it can be achieved?
Can anybody guide me please what is the best practice of adding a debug ClassLib.dll in debug mode and release ClassLib.dll in release mode.
Thanks
Upvotes: 0
Views: 1726
Reputation: 2626
You dont have to worry about these Debug release configurations. Just add a reference from the Release path of the dll into your .exe project. And add the dll library Project into the solution in visual studio. Set the dependency of .exe project to compile dll by right clicking on solution and go to Project Dependencies. Choose your exe project in combo box and check the checkbox of dll project. this will always ensure that dll project is compiled before exe is compiled.
Upvotes: 1
Reputation: 9
You can include your class library project to your solution with .exe project and add project reference for .exe project instead of direct reference to ClassLibrary.dll. And when you start building your .exe project in release mode all related project will be built and referenced in release mode. The same for debug mode.
Upvotes: 0