So this has been bugging me for a while, but sometimes in my Visual Studio 2013 ASP.NET MVC4 project, I will delete an unused ViewModel class, and will get an error on the next compile that looks like this (for a ViewModel called "MostRecentMemberListing.cs" that I just deleted):
Error 9 The type or namespace name 'MostRecentMemberListing' does not exist in the namespace 'MembershipCenter.ViewModels' (are you missing an assembly reference?) c:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\temp\3e932790\42b7ff67\App_Web_cvlbfbci.1.cs 29 MembershipCenter
If I double-click the error in the "Error List" panel of VS, it opens a file located in this path: C:\Windows\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\temp\3e932790\42b7ff67
, which is a system-generated view file(?) with a classname of _Page_Views_Home_MostRecentMember_cshtml
.
I've tried deleting the weird file itself, as well as its containing folder, and ITS containing folder, all the way up the path to the temp
folder under Temporary ASP.NET Files
. But everytime I re-compile my project all those folders and files are re-created in that directly and I get the same compile error.
I am building my Views during the compilation, via <MvcBuildViews>true</MvcBuildViews>
in the project file. If I turn this setting off, I can build + run just fine, but when I turn it back to true
, the build error returns.
Has anyone encountered this error before? Is it related to IIS? I am running Local IIS, not IIS Express.
This is not related to IIS, local or otherwise. That long, strange file name you are seeing is the name the compiler gives to a view when it compiles it. What everything you have described is telling you is that you have a compilation error in one of your views. It could be mismatched HTML tags, a bad model property call, etc.
Looking at your error message, you have a view in the /Views/Home/MostRecentMember.cshtml
. Further, it appears that you are indeed either missing the namespace for your model declaration or declared the wrong namespace for the model that you are trying to send in.
Deleting the strangely named file will do nothing as when you rebuild, it will come back, most likely with a different name.
I had this again today, there must be a bug in visual studio that causes it to try and compile all cshtml files in the views folder. Even if they are not part of the project. Your best bet is to click show all files in the solution explorer, find the rogue file and delete it.
I faced the same error after I changed the namespace of web application, I also renamed my solution and web project also. After lots of tricks and tips finally this solution worked for me.
Finally I searched in web.config listed under Views folder in solution and there I found reference of old name space under. Changed this to NewNamespace and ran the application. This time it worked.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With