locked
Register COM Interop in VS2010 RRS feed

  • Question

  • Hi,

    The register COM Interop function in VS2010 does not work for 64-bit dll. Does the VS2010 SP1 fix it?

    Thanks 

    • Moved by Andrew.Wu Tuesday, May 24, 2011 10:05 AM (From:Visual Studio Setup and Installation)
    Monday, May 23, 2011 4:12 PM

Answers

  • As described in this KB: Issues with building a project with "Register for COM interop" for a 64-bit assembly, Visual Studio itself is 32bit, and use 32bit Regasm.exe internally to achieve "Register for COM interop" feature, so you may receive errors when apply "Register for COM interop" for a x64 project;

     

    To work around the problem, add a post build command to call the 64-bit version of RegAsm.exe using the following steps.

     

    1. In the project properties, select “Build Events…” from the Compile page.

     

    2. Add the following post build command line

     

    "%Windir%\Microsoft.NET\Framework64\v2.0.50727\regasm" "$(TargetPath)"

    Or

    "%Windir%\Microsoft.NET\Framework64\v4.0.30319\regasm" "$(TargetPath)"


    Eric Yang [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.

    • Marked as answer by Chasxu Thursday, May 26, 2011 10:08 AM
    Thursday, May 26, 2011 1:34 AM

All replies

  • Hi Chasxu,

    Thanks for your post.

    According to your description, it appears your question is Off-Topic in this Visual Studio installation forum, so I'm going to help move your question to the appropriate Visual Studio Debugger forum for better support.

    The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who the forums regularly can either share their knowledge or learn from your interaction with us.

    Thank you for your understanding.

    Have a nice day.


    Andrew Wu [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.

    Tuesday, May 24, 2011 10:04 AM
  • You can try the 64bit version of Regasm.exe which could be found at "C:\Windows\Microsoft.NET\Framework64\v4.0.30319".


    Eric Yang [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.

    Wednesday, May 25, 2011 2:58 AM
  • Hi, I could use the 64-bit regasm in post build. But want to know if there is any fix to VS2010 to enable 'register COM for interop' to use the 64-bit regasm automatically.
    Wednesday, May 25, 2011 9:06 AM
  • As described in this KB: Issues with building a project with "Register for COM interop" for a 64-bit assembly, Visual Studio itself is 32bit, and use 32bit Regasm.exe internally to achieve "Register for COM interop" feature, so you may receive errors when apply "Register for COM interop" for a x64 project;

     

    To work around the problem, add a post build command to call the 64-bit version of RegAsm.exe using the following steps.

     

    1. In the project properties, select “Build Events…” from the Compile page.

     

    2. Add the following post build command line

     

    "%Windir%\Microsoft.NET\Framework64\v2.0.50727\regasm" "$(TargetPath)"

    Or

    "%Windir%\Microsoft.NET\Framework64\v4.0.30319\regasm" "$(TargetPath)"


    Eric Yang [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.

    • Marked as answer by Chasxu Thursday, May 26, 2011 10:08 AM
    Thursday, May 26, 2011 1:34 AM
  • Hi Eric,

    I know we can use the post build command as I mentioned in my previous post.  Just want to if we have to use it to register for COM interop for 64 bit assemblies. If there is no fix to the VS2010, that's fine I could use the post build.

    Thursday, May 26, 2011 10:08 AM