Bill Nadeau
Bill Nadeau

Reputation: 722

Unable To Reference Wizard Assembly in VSIX Deployed Template

I am trying to create a VISX extension for Visual Studio 2010 that contains a few project templates. These templates aren't very complex, but I want to expose some additional configuration for them during creation via a wizard. I have successfully set up my VISX package to deploy the templates to the directory structure I want in VS2010, but as soon as I try to configure and run a wizard, I receive an error when I create the template along the lines of:

Error: this template attempted to load component assembly 'My.Assembly, Version 1.0.0.0, Culture=neutral, PublicKeyToken=...

My current configuration is as follows:

The .vstemplate files point to their wizards like this:

<WizardExtension>

<Assembly>My.Assembly, Version=1.0.0.1, Culture=neutral, PublicKeyToken=a494da9e6e53f845, Custom=null </Assembly>

<FullClassName>My.Assembly.Wizard</FullClassName>

</WizardExtension>

This, as far as I can tell, is how I'm supposed to do it. What exactly is going wrong? It looks like it can't find the assembly. Are there any other steps I need to take in order to get the assembly visible to the templates? The assembly is deployed to the extension folder when it is installed (I verified this), so it is at least making it out. Is there something special I need to do to the .vstemplate files to tell them to look in the extensions folder vs the GAC? Did I just miss something?

Note that I have found several pages on the internet stating that I have to GAC the assembly manually or with a script. However, few had my exact scenario (Project template templates being referenced by a VISX project, most examples are using a regular project exported via the project template wizard and having their packages dumped into the VISX folder structure). The only one I found that matched my scenario was an example from Microsoft. I tried to match that, but alas it still does not work. I tried relocating the project I downloaded to reference in this question but I cannot find it again, though.

Using scripts is how we've done this before, but I want to try and make things a little cleaner using VISX packages. I would like to avoid this, but if it's mandatory to script the VISX to install the template to GAC, I can do that.

Upvotes: 6

Views: 4135

Answers (3)

Albert
Albert

Reputation: 1078

I run into the same problem, but mine came to light when I updated the AssemblyVersion of my wizard project. I checked and the versions in the manifest files matched as they should.

I simply went into C:\Users\Albert\AppData\Local\Microsoft\VisualStudio\16.0_c340331cExp\Extensions, found my extension and deleted it there. Now it works again.

(Note that I did find a few others since I've since changed the company name etc, in the AssemblyInfo file, so it could be the old ones laying around that also caused this)

Upvotes: 0

RDV
RDV

Reputation: 1026

I am using VS2015 and faced this issue on and off. When I started building VSIX project with Wizard implementation, everything worked fine for sometime (4-6 weeks) and suddenly it stopped working. After a couple of weeks it would start working again and stop working without notice. Took me long time to find a workaround (still don't know why it suddenly stops).

This is how my VSIX project is built

  1. I have VSIX project, project template and Wizard implementation in the same solution.
  2. VSIX and Wizard implementation are in the same project.
  3. Added VSIX project dll and project template as Assets in VSIX project source.extension.vsixmanifest.
  4. Project template *.vstemplate has Wizard section which refers to VSIX project with strong name: <<<<<<<<<<<<<<<<<<<<<<

    <WizardExtension>
        <Assembly>Test.Template.TemplateInstallerWizard, Version=1.0.0.0, Culture=neutral, PublicKeyToken=30ab381f68dc4f5e</Assembly>
        <FullClassName>Test.Template.TemplateInstallerWizard.WizardImplementation</FullClassName>
      </WizardExtension>
    

None of these worked for me

  1. Uninstalled extension from VS regular instance via Tools->Extensions and Updates..
  2. Uninstalled extension from VS experimental instance by launching VS exp instance from VS2015 command prompt as Administrator:

    devenv.exe /rootsuffix exp

    and then uninstalling the extension via Tools->Extensions and Updates..

  3. Using short named assembly as explained by @Ethan Wu.

  4. Installing templates via this command from VS2015 command prompt launched as administrator:

    devenv /installvstemplates

  5. Rebooting VS2015, my machine several times during this process.

This is what worked for me (thanks to @Ethan Wu)

  1. Remove certificate from VSIX project.

  2. Remove strong name from Project Template *.vstemplate file
  3.     <WizardExtension>
          <Assembly>Test.Template.TemplateInstallerWizard, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null</Assembly>
      <FullClassName>Test.Template.TemplateInstallerWizard.WizardImplementation
    

  4. Clean and build the project.
  5. Remove extension from VS regular instance and close VS2015 (not absolutely required)
  6. Install the extension.
  7. Open new VS2015 instance and try to create the project with wizard.


Couple of things to help debug

  1. When VSIX project is build, in bin\debug folder a file is created -extension.vsixmanifest which has the assets type.

  2. Look for Asset Type="Microsoft.VisualStudio.Assembly": AssemblyName value is what is expected in project template's *.vstemplate WizardExtension section - they should match exactly.

  3. After installing extension, go to VS2015 extension location on local box:

    %appdata%\..\Local\Microsoft\VisualStudio\14.0\Extensions\<some_temp_folder>
    

    open extension.vsixmanifest to ensure that Asset Type="Microsoft.VisualStudio.Assembly" AssemblyName value is correctly populated. If required, you can change this value and restart VS2015 to make this in effect.

Hope this will help someone and save tons of time as there is very little help on Wizard and custom project templates.

Thanks,

RDV

Upvotes: 1

Ethan Wu
Ethan Wu

Reputation: 428

When deploy the wizard based project template by VSIX Extension, it is better to use Short-Named assembly in .vstemplate. This can avoid the GAC deployment.

In your case, it should be:

<WizardExtension>
 <Assembly>My.Assembly</Assembly>
 <FullClassName>My.Assembly.Wizard</FullClassName>
</WizardExtension>

Upvotes: 2

Related Questions