Added Nuget packages to multi project solution template - visual-studio-2010

After going the http://docs.nuget.org/docs/reference/packages-in-visual-studio-templates
I was able to configure nuGet package as a part of VSIX package for a single project template.As per the link we need to add Wizard Extension element to VSTEMPLATE of project template.
<WizardExtension>
<Assembly>NuGet.VisualStudio.Interop, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</Assembly>
<FullClassName>NuGet.VisualStudio.TemplateWizard</FullClassName>
</WizardExtension>
The problem begins when I want a custom Wizard implementing IWizard interface to be binded to the project template.To do this,I need to add a dll containing IWizard implementation to GAC and add the dll details the Wizard Extension element to VSTEMPLATE of project template again.
So I want both then I will have something as below in VSTEMPLATE of project template
<WizardExtension>
<Assembly>NuGet.VisualStudio.Interop, Version=1.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a</Assembly>
<FullClassName>NuGet.VisualStudio.TemplateWizard</FullClassName>
<Assembly>XXXXXXX, Version=1.0.0.0, Culture=neutral, PublicKeyToken=96268505a6009a69</Assembly>
<FullClassName>XXXXXXX.ProjectTemplateWizard</FullClassName>
</WizardExtension>
In above scenario, the template will load only assembly,it does not recognize the second assembly.
Is there any way of doing it.
Regards,
Qureshi

Instead of having 2 assenblies in 1 extensionwizard element, try having 2 wizardextension elements and a seperate wizarddata element fornuget dll.

Related

Using PrecompiledMvcEngine FindView throws InvalidOperationException and looks for View cshtml files

I got an InvalidOperationException when the MVC controller tried to FindView while using the PrecompiledMvcEngine.
Using on a machine that has VS2012, MVC4 and deployed to IIS
After looking at the source code of ControllerBase.FindView to ViewEngineCollection.FindView to VirtualPathProviderViewEngine to PrecompiledMvcEngine, found that _mappings in PrecompiledMvcEngine had a count of 0. (Tx to Reflection and Open source.)
The reason is that there was not Type assignable to WebPageRenderingBase in my project's DLL. On decompiling my dll, it actually had the compiled views, and the views extended from WebPageRenderingBase.
After writing a unit test to do the same thing that PrecompiledMvcEngine does to load views, found that they are using different versions of the WebPageRenderingBase class. RazorGenerator.Mvc uses System.Web.WebPages v1.0.0.0 to precompile at build time. The PrecompiledMvcEngine uses System.Web.WebPages v2.0.0.0 when loading types from the compiled assembly. Fixed this by changing my MVC csproject to also load v1.0.0.0 at runtime.
Changed
<Reference Include="System.Web.WebPages" />
which picked up 2.0.0.0 to
<Reference Include="System.Web.WebPages, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL" />
forcing it to always pick up 1.0.0.0. This problem will often be faced if you are deploying precompiled views to a machine with VS2012 and MVC4 installed, without specifying the correct version in the csproj file

CrystalReports error

I inherited a web app which I'm tasked with maintaining. The application has a dozen or so crystal reports, but I couldn't open them (well, I -could- but they were mostly numeric in nature).
I installed this: http://scn.sap.com/people/coy.yonce/blog/2010/11/12/crystal-reports-for-visual-studio-2010-production-release-now-available
Then, I could open them properly. I made the necessary adjustments to some of them, saved, and attempted to test locally. Before installing crystal reports (above), I ran the application locally and it worked fine.
The problem: Now that I've installed it and made my changes (very minor stuff and only to the rpts, not to any aspx files), I'm getting this error:
Parser Error Message: Could not load file or assembly 'System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The system cannot find the file specified.
Source Error: [No relevant source lines]
Here's what I have in Web.config pertaining to Crystal Reports:
<assemblies>
<add assembly="CrystalDecisions.Shared, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/>
<add assembly="CrystalDecisions.Web, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/>
<add assembly="CrystalDecisions.ReportSource, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/>
<add assembly="CrystalDecisions.CrystalReports.Engine, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>
<add assembly="CrystalDecisions.ReportAppServer.ClientDoc, Version=13.0.2000.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/>
The versions here match the version in the reference's properties.
There are no dlls in the bin folder beyond the application's own dll.
There are the following 'Crystal' related references: CrystalDecisions.CrystalReports.Engine, CrystalDecisions.ReportSource, CrystalDecisions.Shared, CrystalDecisions.Web
I've researched the problem, and some say I need to add an ajax dll. Which one? Also, in what way does that relate?
This was supposed to be a tiny adjustment and it's turning into a big thing at this point. Any help you are able to offer is greatly appreciated.
Thanks!
The problemi is tied to System.Web.Extensions dll, it's not a Crystal Reports problem.
Try removing System.Web.Extensions line in web.config.

How to use wizard assemblies attached in VsixMainfest in project templates?

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
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.
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/

Could not load file or assembly 'System.Data.Entity

I am working within a Solution (a jokes website). The Solution has 2 Projects:
Model (C# Class Library)
MVC 3 Empty Application
I am trying to get my view to list the Jokes in the Database, but I get the following error:
Could not load file or assembly 'System.Data.Entity, Version=4.0.0.0,
Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its
dependencies. The system cannot find the file specified
As you can see from the Error message, I have already added the System.Data.Entity to the web.config of the MVC 3 application.
No matter what I do, I seem to be unable to fix the error! I have added using statements for the Entity class, to the HomeController and the Index.cshtml.
To use an external Entity Framework model (embed in a DLL for example) with ASP.NET MVC 3 you must :
Add the following reference to your MVC project : System.Data.Entity (Version 4.0.0.0, Runtime v4.0.30319)
Add the following line in your web.config
...
< compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" />
</assemblies>
</compilation>
To resolve this error:
Go to references section in your project
Right click it and than go add library package reference.
search in online tab for entity framework
you will get a lot of installed packages if u have internet connection enabled
Select EF4 package, and finally, add it
If you have any entity frame work installed and you are getting an error then click for add reference and in Browse tab go to below location:
C:\Program Files\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0
Select to find System.Data.Entity.dll and then add it. This will resolve this issue.
I was getting the same error, and it was because the MVC3 project used Entity Framework 4.1, and my domain model (in a class library project, same solution) grabbed 4.2 when I added the reference.
I uninstalled EF from my Web project, then reinstalled, now both have 4.2 and are working fine.
Currently working with the Apress title, Pro ASP.NET MVC Framework (Freeman).
another way to solve this is to add empty edmx file (Add -> Class -> Data -> ADO.NET Entity Data Model) and delete it afterwards.
I am not sure what the Visual Studio Wizard does, but it`s a common problem at my machine and i always fix it like that.
Make sure you have referenced the System.Data.Entity assembly in your project. Not only in the web.config assemblies section but also those assemblies being referenced. Also make sure that the System.Data.Entity, V4.0.0.0 is present in the GAC on the server you are running this application.

Migrating MVC2 to MVC3: problem with MVCFutures

I'm trying to migrate an MVC2 project to MVC3 - i've followed the instructions within the release notes and the app will compile, but the project depends on a few helpers located inside the previous MVCFutures and tosses:
Compiler Error Message: CS1061: 'System.Web.Mvc.HtmlHelper' does not contain a definition for 'SubmitImage' and no extension method 'SubmitImage' accepting a first argument of type 'System.Web.Mvc.HtmlHelper' could be found (are you missing a using directive or an assembly reference?)
My solution includes a Lib folder, inside of which is:
MVCFutures\Microsoft.Web.Mvc.dll
Do i have an upgrade option here?
use this tools for upgrading:
http://blogs.msdn.com/b/marcinon/archive/2011/01/13/mvc-3-project-upgrade-tool.aspx
#justSteve,
First off, you can download the MVC3 source from codeplex, which includes the MvcFutures code, and just build the new futures assembly yourself.
However, I'd be willing to bet that your problem is a missing using statement somewhere.
Make sure your page has a using namespace statement for Microsoft.Web.Mvc.
If you're trying to migrate to Razor (which you didn't say, but just in case), you can put a namespace reference in the web.config file contained in your Views folder (to avoid having to include the using statement in each of your views), like this:
<system.web.webPages.razor>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<pages pageBaseType="System.Web.Mvc.WebViewPage">
<namespaces>
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
<add namespace="Microsoft.Web.Helpers" />
...
</namespaces>
</pages>
</system.web.webPages.razor>
You mentioned that your MVC futures binary is located in a Lib folder. Make sure that:
Your project has an assesmbly reference to that library
The MvcFutures dll is being copied to the bin folder
Your web.config has an assembly reference to MvcFutures
Could you also clarify if the exception you are seeing is when compiling your app in Visual Studio (because you are using MVC futures methods in your controllers or data models) or when you access your application in the browser (because you are using futures in your views).
Btw, an upgraded version of MVC Futures that targets MVC 3 will be released soon.
Update: The source code for MVC 3 Futures is already available on codeplex: http://aspnet.codeplex.com/releases/view/58781 so you can compile it yourself.
For upgrading your views you might want to try this from Telerik...
https://github.com/telerik/razor-converter
...it will convert your webforms views to razor.
Regards
Paul

Resources