Multi-project solution, including dll's in final program
I have one solution with two example projects. One is an exe Windows Forms final program and one is a dll library. I see, that final exe works perfectly on different computers. So.. Do i have to include additionally SecondProject.dll with my FirstProject.exe when sharing my program with others? Or is the dll file already included inside the FirstProject.exe file?
I am confused because I've tested the FirstProject.exe file on few computers and it works 开发者_高级运维perfectly. Am I missing something?
[SOLVED] details in my answer below..
No, a DLL assembly has to be distributed with the exe. The only reason it works on different computers without error is that maybe your exe doesn't actually USE the DLL. The dll is loaded when you first use a class or call a method from that assembly.
Another reason may be that you catch all exceptions in your code, including the DLLNotFoundException
and it SEEMS your code is working, whereas in reality it doesn't do what you expect it to...
In any case you can't link statically to a library in .NET.
If the DLL in question is not lazy-loaded, and your application works without the said DLL, then there is no need for it. You can safely delete it.
If you not call any function in dll or not using dll in exe then dll no need to include.
Solved.. I don't know why but Clean / Rebuild Solution|Projects didn't work correctly. Everything started working (or stopped) as it should, after manual deletion of bin and obj subdirs in both projects and clean solution rebuild.
Now it does not work without dll. As it should not to.
精彩评论