问题
I have a vsixmanifest file that has an assembly attribute. The file looks like:
<Content>
<ProjectTemplate>Solution</ProjectTemplate>
<Assembly AssemblyName="SolutionNameWizard, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1c39bfcc-223f-4c12-a5dc-55eeca7c61f7">
Assemblies\SolutionNameWizard.dll
</Assembly>
I know that the assembly name and public key are correct.
Now, I am trying to use this assembly in one of my templates. Right now I have:
<WizardExtension>
<Assembly>SolutionNameWizard, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1c39bfcc-223f-4c12-a5dc-55eeca7c61f7</Assembly>
<FullClassName>SolutionNameWizard.IWizardImplementation</FullClassName>
</WizardExtension>
Is there something that I am missing? When I run the vsix I get the following error:
A problem was encountered creating the sub project 'test.Web' Error: this template
attemtped to load component assembly 'SolutionNameWizard, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1c39bfcc-223f-4c12-a5dc-55eeca7c61f7'.
I know that templates require the assembly to be in the GAC, is that also the case when I am using vsix? I was hoping to avoid the GAC and still use my wizard.
EDIT: I changed the public key to the proper string as suggested in the answers, but am still having the issue.
Edit 2: in addition to the helpful answer below, here is a blog that I wrote after I finished this process. It links to a bunch of articles that I found to be very helpful: https://thebhwgroup.com/blog/2013/10/visual-studio-templates
回答1:
If your assembly is being provided via your VSIX, it does not need to be in the GAC.
Your PublicKeyToken is definitely not correct. You're using a Guid when it should be a 16-character hex string (8 bytes). See the following example:
MyAssembly, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
You can find the PublicKeyToken value for your assembly by running sn.exe -T MyAssembly.dll
from a VS command prompt.
回答2:
If anyone else happens to stumble upon this question, I ended up following this guide: http://blog.tonysneed.com/2011/09/14/build-a-multi-project-visual-studio-template/
It made the process (mostly) very easy. If anyone happens to run into similar issues, feel free to contact me and I can try to share what I learned.
Edit: here is short blog article I wrote after completing this process. It might be helpful for someone who stumbles upon this: http://www.thebhwgroup.com/blog/2013/10/visual-studio-templates/
来源:https://stackoverflow.com/questions/11568280/how-to-use-wizard-assemblies-attached-in-vsixmainfest-in-project-templates