locked
Export template as VSIX results in MSB3212 error when user's install template and create projects RRS feed

  • Question

  • I have a class lib vb .net project in VS 2010 from which I create a template. The class in the lib has a guid and progid attribute and is com visible. In the project settings for compile I also have the "register for com interop" button checked.

    I can run file\export template and create a template. This template works fine. I can open VS 2010 and go to file new project and under the vb projects find the template and create a project. I can compile fine and the assembly is registered for com interop (and a COM app can CoCreate an instance). So everything works great.

    Then I found the extension manager and decided that uploading to the on-line Gallery would be a great idea. So I installed EM and opened my original template project again and this time ran the file/export template as VSIX command. My template exports and I have a .vsix file that I then double-click to install.

    Once again the project template shows up in the file new project UI. But this time when I create a project and install, I get this:

    c:\Windows\Microsoft.NET\Framework\v4.0.30319\Microsoft.Common.targets(3341,9): error MSB3212: The assembly "c:\temp\SEAddInNOUIvsixTake21\SEAddInNOUIvsixTake21\bin\Debug\SEAddInNOUIvsixTake21.dll" could not be converted to a type library. Type library exporter encountered an error while processing 'SEAddInNOUIvsixTake21.Addin, SEAddInNOUIvsixTake21'. Error: Element not found.

    Build FAILED.

    This appears to be related to register for COM interop. So I went to the VS 2012 command prompt window and navigated to the bin\debug directory and ran regasm /codebase on the assembly and it registers with no problem. I can also uncheck the "register for com interop" in the compile settings and build with no error.

    I have verified that when running regasm from command prompt window that it uses the same regasm tool (using 'where regasm'). I have also started the VS 2010 command prompt (32 bit edition) and run regasm on the assembly with no issue.

    I found a couple of on-line posts regarding this error and a kb article for an earlier Visual Studio that said this was by design (really) and that I needed to register a visual basic dll using regasm. But we tried that and it made no difference.

    Why would this problem only show up when I export the template as vsix and not as a regular template? And how do I fix this?


    R.D. Holland

    Thursday, June 7, 2012 1:48 PM

Answers

  • I finally extracted the data from the .vsix file using 7-zip and then compared the .vbproj file that was in the .vsix file to the .vbproj file of my original template. I found that the export template as vsix command modified my .vbproj file. In particular it modified the <ProjectGuid> entry by placing a template parameter there, $guid1$.

    So how does that cause the error? Since this is a template project, I am using template parameters too and I am using $guid1$ (for the GuidAttribute on a class I want to be com visible).

    So I changed my .vb source file to use $guid10$.

    I then exported as .vsix again and verified that the build error is fixed.

    This also made me wonder if I was supposed to templatize the <ProjectGuid> in the project which I use to create the template. Since I have built a lot of projects after exporting as template (not vsix) I searched all the .vbproj files for the test projects and found that each one has a unique guid in the <ProjectGuid> node. So I don't need to parameterize that entry in the .vbproj file when using the standard (non extension manager) export as template command. So I am not sure why export template as .vsix would even need to modify the .vbproj file and thus introduce this problem.


    R.D. Holland

    • Marked as answer by RD Holland Thursday, June 7, 2012 2:57 PM
    Thursday, June 7, 2012 2:57 PM

All replies

  • I finally extracted the data from the .vsix file using 7-zip and then compared the .vbproj file that was in the .vsix file to the .vbproj file of my original template. I found that the export template as vsix command modified my .vbproj file. In particular it modified the <ProjectGuid> entry by placing a template parameter there, $guid1$.

    So how does that cause the error? Since this is a template project, I am using template parameters too and I am using $guid1$ (for the GuidAttribute on a class I want to be com visible).

    So I changed my .vb source file to use $guid10$.

    I then exported as .vsix again and verified that the build error is fixed.

    This also made me wonder if I was supposed to templatize the <ProjectGuid> in the project which I use to create the template. Since I have built a lot of projects after exporting as template (not vsix) I searched all the .vbproj files for the test projects and found that each one has a unique guid in the <ProjectGuid> node. So I don't need to parameterize that entry in the .vbproj file when using the standard (non extension manager) export as template command. So I am not sure why export template as .vsix would even need to modify the .vbproj file and thus introduce this problem.


    R.D. Holland

    • Marked as answer by RD Holland Thursday, June 7, 2012 2:57 PM
    Thursday, June 7, 2012 2:57 PM
  • Hi RD,

    I’m glad to hear that you got it working.

    Thank you for sharing your solutions & experience here. It will be very beneficial for other community members who have similar questions.

    Best regards,

    Ego

    Friday, June 8, 2012 5:04 AM