How to use a Wizard Extension for Item Templates

373 Views Asked by At

I am trying to setup an Item Template where the .vstemplate file contains a reference (WizardExtension) to a .DLL that implements a form to collect custom parameters for the template. I used a Project Template having an example for implementing the Form Wizard, but when I select my template from the Add New... page, I get an error dialog saying: "Error: this template attempted to load component assembly 'MyWizard, version=1.0.0.0, Culture=neutral, PublicKeyToken=xxx'." Does anyone know how I can setup the Item Template to use a form for collecting custom parameters ?

1

There are 1 best solutions below

0
Humble Newbie On

Please check this solution: https://learn.microsoft.com/en-us/visualstudio/extensibility/how-to-use-wizards-with-project-templates?view=vs-2022

Especially clauses 10, 11 and 12. Also, there are examples included as well.

  1. Extract the public key from the key.snk file. In the command window, type

\sn.exe -p key.snk outfile.key.

Don't forget to surround the path of sn.exe with quotation marks if there are spaces in the directory names!

  1. Get the public key token from the outfile:

< location of sn.exe >\sn.exe -t outfile.key.

Again, don't forget the quotation marks. You should see a line in the output like this> Public key token is < token >> Make a note of this value.

  1. Add the reference to the custom wizard to the .vstemplate file of the project template. In the Solution Explorer, find the file named MyProjectTemplate.vstemplate, and open it. After the end of the section, add the following section:
<WizardExtension>
    <Assembly>MyProjectWizard, Version=1.0.0.0, Culture=Neutral, PublicKeyToken=token</Assembly>
    <FullClassName>MyProjectWizard.WizardImplementation</FullClassName>
</WizardExtension>

Where MyProjectWizard is the name of the assembly, and token is the token you copied in the previous step.