System.Web.Helpers does not exist in namespace: WebImage - asp.net-mvc-3

While I know this has been "answered" about 50 million times, I haven't found an answer that fixes the issue for me, so I feel like I have no choice but to ask again.
Previous suggestions:
Razor pages in MVC are giving a compile error with System.Web.Helpers not being found
<add assembly="System.Web.Helpers, Version=1.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
I have added this to my web.config, but the issue remains.
Type or namespace name does not exist
I only have one project, and the targetFramework is 4.0.
I installed Microsoft.Web.Helpers 1.15 (2.0 is incompatible with MVC3.) The Microsoft.Web.Helpers.dll is in my bin folder.
The odd thing is that there's Microsoft.Web.Helpers and System.Web.Helpers. I need System.Web.Helpers in this case, because I'm using WebImage in my code.

As I keep telling people, it's when I ask for help that I find the answer. In my case, somehow in the process of destroying my Solution earlier by upgrading to Microsoft ASP.NET Helper Library 2.0 and then trying to undo that action, System.Web.Helpers stopped being a referenced assembly in my project. Simple fix!
Of course, fixing that led me to the next Assembly Reference error. I think I'll be here all night.

Related

MVC 3 errors with Temporary ASP.NET Files

I am taking over a ASP.NET MVC 3 project from a friend who has not got the time to work on it. I copied across all his files, setup the database etc and then opened it in VS2010. I proceeded to change the MS-SQL connection settings and then started the project in debug mode in VS.
As a note we are both using Framework versions v4.0.30319
It ran fine 100% without issue. I then closed the project, shut off the machine and now need to get started on adding some items to the website. I ran the site with VS again and go an error, specifically with the Frameworks web.config file, saying:
Error 77 Could not load type
'System.Data.Entity.Design.AspNet.EntityDesignerBuildProvider'. C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\web.config
Looking this up I found a resolution to this issue at http://forums.asp.net/t/1698282.aspx/1 and they solved it by adding the following line to the site apps web.config:
<add assembly="System.Data.Entity.Design, Version=4.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089" />
Running the site again now produced two errors:
Error 77 The type or namespace name 'ChangePasswordModel' does not
exist in the namespace 'ComputechIT.Models' (are you missing an
assembly
reference?) c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary
ASP.NET Files\computechit\1111c5a1\826189ca\App_Web_43fo251f.0.cs 184
Error 78 The type or namespace name 'RegisterModel' does not exist in
the namespace 'ComputechIT.Models' (are you missing an assembly
reference?) c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary
ASP.NET Files\computechit\1111c5a1\826189ca\App_Web_43fo251f.2.cs 184
Researched further and found that someone mentioned removing the obj directory and contents from within the project folder, which I did, to no avail.
So am a little stumped now as to why this site worked fine the first time I used it. Something seemed to have changed between then and when I next turned on the PC and tried to run the site.
I've done no updates of any sort on this PC. Any help would be appreciated.

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

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/

Expression Blend Sketchflow reference build error

I'm working on a mobile application prototype in Expression Blend 4. Up until now it has worked fine, but after re-opening the program I can no longer build the project. I get 4 errors that are all pretty much the same:
The primary reference "System.Windows.Controls.Toolkit, Version=5.0.5.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" could not be resolved because it has an indirect dependency on the .NET Framework assembly "mscorlib, Version=5.0.5.0, Culture=neutral, PublicKeyToken=7ceec85d7bea7798e" which has a higher version "5.0.5.0" than the version "2.0.5.0" in the current target framework."
Yeah, pretty lengthy error message (which I had to type out as you can't copy from the error output!). The other 3 errors are identical but refer to different .NET Framework Assemblies (System, System.Core and System.Windows)
Any pointers on how to fix this?
It sounds like you're trying to edit a Silverlight 5 project in Expression Blend 4. That won't work: you need the Blend Preview for Silverlight 5. Last I checked, Microsoft has not yet released final bits for this. :/

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.

Resources