The Name Model does not exist in the current context ASP.NET MVC

Adding a PlugIn to NopCommerce 3.2, and in the views I get the error mentioned above, but also for 'Layout' and 'Html'. I have copied the same Web.Config that works in another plugin. I have also added the same references as used in the working Plugin. When compiling the plugin works, but I don't have any intellisense and can't trust that VisualStudio marks errors correctly.

I am using VS2013 Professional Update 1.

Answers

This error was probably caused by Resharper. We are a team of three developers using GIT. One of us installed Resharper, and this probably caused the error for the other two of us. When we installed Resharper trial it suddenly worked again. Unfortunately it isn't working when uninstalling Resharper again...

Try to add this section in system.web. (Make sure the versions i added are indeed the ones you are using)

<compilation targetFramework="4.5">
  <assemblies>
    <add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    <add assembly="System.Web.Helpers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    <add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    <add assembly="System.Web.Mvc, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
    <add assembly="System.Web.WebPages, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
  </assemblies>
</compilation>

If you change your project properties to target 4.5.1,

targetFramework in LOTS of other places will still say 45

You can find targetFramework 3-4 times in your root web.config and in all kinds of packages.config.

I had same problem, change Project to target 4.5 and it cleared up.

Best to not target 4.5.1.


Post a Comment

Previous Post Next Post