none
C# Register for COM Interop with external dll (copy local = false)

    Question

  • I have a project that "Register for COM interop".  It references a few dlls, which are not copied locally (intentionally).   Because of this, register to coms will fail because it can't find the dlls, even though the relative paths are set in the "Project References".  

    Is there a way to get around this?

    Tuesday, September 27, 2011 5:14 PM

All replies

  • What type of application is this: Web, Winform?

    We had the same issue recently where our IIS server couldn't find the .dlls for an MVC app.  We had to install the latest version of MVC (3) in order to make teh .dlls available.


    jboyd
    Tuesday, September 27, 2011 5:19 PM
  • We have Interop functions to call things like ArcGIS and other third party software.  Its not a version issue, its Visual studio 2008 not finding my own dlls we created in another directory.  VS found them because it used them to build the solution but when it comes time to register, it forgot them for some odd reason.   
    Tuesday, September 27, 2011 5:26 PM
  • If u can change ur project structure / set up a post build process which will copies all the assemblies and dependences copy to a specific folder and then u wont have any issues in dependencies issue.


    --Krishna
    Tuesday, September 27, 2011 5:28 PM
  • I'm trying not to do any copy.  Is there a way to do it from multiple directory?  For example,

     

    regasm /codebase ..\..\..\..\..\projectA\bin\;..\..\..\projectB\bin\;  ..\..\..\..\..\projectC\bin\

    Tuesday, September 27, 2011 5:32 PM
  • try with asmpath:Directory attribute. Not sure.

    regasm /asmpath:Directory;  ..\..\..\..\..\projectC\bin\

    Here is MSDN help

     


    --Krishna
    Tuesday, September 27, 2011 5:55 PM
  • Still not working properly.  Anyone have an example of this working?  Or is there another way to tell VS to use the "Project Reference" instead of looking in the local directory?
    Tuesday, September 27, 2011 6:26 PM
  • Thanks jboyd and Krishna for your help.


     

    Hi Sanh,

    Welcome to MSDN Forum.


    1. Please ensure that such relative path “..\..\..\..\..\projectA\bin\” is available based on the current folder where the regasm.exe command tool is running.

    2. The option /asmpath:directorymust be used with the /regfile option.

    The option /asmpath:directoryspecifies a directory containing assembly references.

    e.g. regasm myTest.dll /asmpath:C:\ /regfile:myTest.re

    3. You can add multiple search paths into system environment variables, so that the regasm.exe can search assembly references from multiple directories.

     

     

    There are some cases discussing the similar issues for your reference.

    Case: regasm.exe requires asmpath to find framework dlls on some PCs

    http://social.msdn.microsoft.com/Forums/en/csharpgeneral/thread/10c2494f-508d-48e2-bdfb-a558b158756b

    Case: Multiple search paths for assemblies not in the GAC when using REGASM & COM

    http://stackoverflow.com/questions/3221043

     

     

    If you have any suggestion or feedback, you‘re welcome to submit it to Microsoft Connect feedback Center.

    http://connect.microsoft.com/VisualStudio/

     


    Martin Xie [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

     


    Thursday, September 29, 2011 11:36 AM
    Moderator