locked
Build fails when checked "Register for COM interop" RRS feed

  • Question

  • Hi all,

    I met a odd issue. My OS is Win7 32bit with Office 2007 and I used VS2010 SP1 to create a new Word 2007 AddIn project. I want to make this addin can be called through COM. So, I did

    1) Checked "Make assembly COM-visible"

    2) Checked "Register for COM interop"

    3) Set target CPU as AnyCPU

    Whe I built, it showed below message and build failed.

    C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(3341,9): error MSB3211: The assembly 'Microsoft.Office.Tools.Common.v4.0.Utilities, Version=10.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' is not registered for COM Interop. Please register it with regasm.exe /tlb.
    C:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(3341,9): error MSB3212: The assembly "C:\Users\VW\Documents\Visual Studio 2010\Projects\Solution1\LabWordAddIn\bin\Debug\LabWordAddIn.dll" could not be converted to a type library. Type library exporter encountered an error while processing 'LabWordAddIn.ThisAddIn, LabWordAddIn'. Error: Error loading type library/DLL.

    If I switch to .NET Framework 3.5, it will work fine. Is this a bug? How can I solve this problem?

    Thanks a lot.

    Tuesday, September 6, 2011 2:05 AM

Answers

  • Hi Chris Jensen,

    Thanks for your answer, but I didn't upgrade the project file from Visual Studio 2008, it is a brand new Visual Studio 2010 Office project for Visual Basic. I followed your steps and I can't find SecurityTransparentAttribte in my AssemblyInfo.vb.

    I tried to use Post-build and regasm to avoid this problem. But I met another odd issue, the macros do not work for VSTO project of Visual Basic, all the marcros returned empty string in Post-build event. Fortunately, I found macros of MSBuild still work and I used them in my Post-build. It works fine for now.

    Here is my workaround, it may helps other people have same issue:

    1) Unchecked "Register for COM interop"

    2) In "Post-build Event Command Line", input "%Windir%\Microsoft.NET\Framework\v4.0.30319\regasm" /codebase /tlb "$(MSBuildProjectDirectory)\$(OutputPath)$(AssemblyName).dll"

    3) Build project as usual

     

    Tuesday, September 13, 2011 3:35 AM

All replies

  • Hello Wade Wu , 

    In case you are migrating a VSTO add-in project from VS 2008 to VS 2010 and targeting new Framework 4.0 then you have to remove obsolete attributes from the projects.

    You upgrade an Office project from Visual Studio 2008. In this case, you must remove the SecurityTransparentAttribute.

    Visual Studio does not automatically remove these attributes when the target framework is changed.

    StepsTo remove the SecurityTransparentAttribute
    With the project open in Visual Studio, open Solution Explorer.
    Under the Properties node (for C#) or the My Project node (for Visual Basic), double-click the AssemblyInfo code file to open it in the code editor.
    Locate the SecurityTransparentAttribute and either remove it from the file or comment it out.

    See if this helps resolve your problem. Let us know what you learn. Thanks

    Regards,
    Chris Jensen
    Senior Technical Support Lead

    • Edited by cjatms Monday, September 12, 2011 5:34 PM
    Monday, September 12, 2011 5:34 PM
  • Hi Chris Jensen,

    Thanks for your answer, but I didn't upgrade the project file from Visual Studio 2008, it is a brand new Visual Studio 2010 Office project for Visual Basic. I followed your steps and I can't find SecurityTransparentAttribte in my AssemblyInfo.vb.

    I tried to use Post-build and regasm to avoid this problem. But I met another odd issue, the macros do not work for VSTO project of Visual Basic, all the marcros returned empty string in Post-build event. Fortunately, I found macros of MSBuild still work and I used them in my Post-build. It works fine for now.

    Here is my workaround, it may helps other people have same issue:

    1) Unchecked "Register for COM interop"

    2) In "Post-build Event Command Line", input "%Windir%\Microsoft.NET\Framework\v4.0.30319\regasm" /codebase /tlb "$(MSBuildProjectDirectory)\$(OutputPath)$(AssemblyName).dll"

    3) Build project as usual

     

    Tuesday, September 13, 2011 3:35 AM
  • Hi Wade Wu,

    Thank you for sharing your solution.

    Regards,
    Chris Jensen
    Senior Technical Support Lead

     


    • Edited by cjatms Tuesday, September 13, 2011 1:43 PM
    Tuesday, September 13, 2011 1:42 PM
  • Yep the office stuff is all over the place! Most of the msdn examples take us down the wrong route! I also had this problem and did not upgrade from 2008. My workaround around in win7 64 bit was to run vs as administrator. But the click once installer still fails.

    BTW: Microsoft I can not add any new replies to this site using IE. I get an empty jscript prompt when I click Save. I had to use Chrome to post this message!!

    Friday, September 14, 2012 3:02 PM
  • Thank you very much. You have saved my mental health ... ;-) ... I have tested xxx.Object from other AddIn ... it was there ... from external app was not ... Thank you again!
    Sunday, August 4, 2013 5:49 PM