When I use the codedomprovider compiler I add .NET references by simply adding the path name:
foreach (string str in referenceList)
{
cp.ReferencedAssemblies.Add(str);
}
This works okay when normal .NET libraries but when I add my own .dll the compiled EXE will only work if the .dll is in the root folder of the EXE even if the path was set at something different. Why is this? Can the codedom by set to copy the dll to the root automatically so it doesn't throw this error?
Last edited by wurdup; August 21st, 2011 at 07:59 AM.
This works okay when normal .NET libraries but when I add my own .dll the compiled EXE will only work if the .dll is in the root folder of the EXE even if the path was set at something different. Why is this??
Assuming each str includes the full path of the assembly, it must ignore the path info and therefore can't find the dlls.
Originally Posted by wurdup
Can the codedom by set to copy the dll to the root automatically so it doesn't throw this error?
the str is the full path yes. When it uses the standard .net it works ok ie c:/program files/Reference Assemblies/Microsoft/Framework/.NETFramework/v4.0/Profile/Client/System.dll
but when i use my own dll c:\myfolder\myLib.dll the compiled EXE throws a file not found error because it's looking for the dll in the exe folder. There must be a way for the compiler to do it automatically because VS2010 does it when I add the dll reference to my working project. It will save the dll to the bin/debug folder when I hit build and run.
I could do it manually by code to copy the dll there but how do I know which dll should be copied and which shouldn't? Not all standard libraries are in the \Reference Assemblies\ folder.
Bookmarks