CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Aug 2010
    Posts
    17

    codedomprovider references help

    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.

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: codedomprovider references help

    Quote Originally Posted by wurdup View Post
    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.
    Quote Originally Posted by wurdup View Post
    Can the codedom by set to copy the dll to the root automatically so it doesn't throw this error?
    Probably not, but you can do this yourself.

  3. #3
    Join Date
    Aug 2010
    Posts
    17

    Re: codedomprovider references help

    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.

  4. #4
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: codedomprovider references help

    The standard libraries are found because they are registered in the GAC.

  5. #5
    Join Date
    Aug 2010
    Posts
    17

    Re: codedomprovider references help

    okay will try and find out how to copy dll if not registered thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured