简体   繁体   中英

0x80070002 error when creating new ASP.NET MVC 4 Web Application in VS2012

I'm trying to create a new ASP.NET MVC 4 Web Application, when this message pops up after selecting a project template (eg Empty) and pressing OK:

错误信息

I am running Windows 8 Professional with Visual Studio 2012 Professional.

So far I've tried a few minor things:

  • Running VS2012 as Administrator
  • Running devenv /setup from the Developer Command Prompt
  • Reinstalling Microsoft ASP.NET MVC 4 from http://www.asp.net/downloads
  • Running Repair fromt he VS2012 Installer
  • Installing Visual Studio 2012 Professional from scratch

None of the above steps has helped, so something is probably broken somewhere.

Has anyone experienced something similar to this before? Any ideas would be greatly appreciated.

Feel free to ask for more information, logs or whatnot if you require it :)

That would work, but it's not the safest thing to do.

The MVC wizard is a shared component in VS, ie. There is one copy of the DLL that lives in Common7\\IDE.

When you installed the 2012.2 update, and then installed another SKU altogether, you have the old templates from the new SKU with the new wizard. What you should do in this situation is the following:

  1. Install Express 2012
  2. Install Web Tools 2012.2 update (this drops the 4.1 templates)
  3. Install VS Pro 2012 (MVC templates will not work)
  4. To fix this, you need to go to Add/Remove Program and Repair "Microsoft ASP.NET Web Frameworks and Tools 2012.2". The repair operation will figure out that you are missing the updated MSIs for the VSPro SKU and install it for you.

Jacques

From Jacques (who writes the installers):

Sounds like the files are missing from the project template cache.

If he has everything installed then he could try the following

  1. Shut down all instance of VS
  2. Delete the ProjectTemplatesCacheFolder from Program Files\\Microsoft Visual Studio 11.0\\Common7\\IDE\\ProjectTemplatesCache
  3. Launch the VS developer command prompt as administrator
  4. Run devenv /setup
  5. Confirm that the ProjectTemplateCache has been rebuilt

If the cache doesn't rebuild then there is something more serious wrong on the system.

This happened to me after I installed VS 2012 Pro on a machine with VS 2012 Express (and vice versa). The thing is they were using different versions of MVC 4 templates. One was using:

  • BasicMvcWebApplicationProjectTemplatev4.0.csaspx
  • BasicMvcWebApplicationProjectTemplatev4.0.cshtml
  • EmptyMvcWebApplicationProjectTemplatev4.0.csaspx
  • EmptyMvcWebApplicationProjectTemplatev4.0.cshtml
  • MvcWebApplicationProjectTemplatev4.0.csaspx
  • MvcWebApplicationProjectTemplatev4.0.cshtml
  • ...

The other:

  • BasicMvcWebApplicationProjectTemplatev4.1.csaspx
  • BasicMvcWebApplicationProjectTemplatev4.1.cshtml
  • EmptyMvcWebApplicationProjectTemplatev4.1.csaspx
  • EmptyMvcWebApplicationProjectTemplatev4.1.cshtml
  • MvcWebApplicationProjectTemplatev4.1.csaspx
  • MvcWebApplicationProjectTemplatev4.1.cshtml
  • ...

You can check it here:

VS 2012 PRO

C:\\Program Files (x86)\\Microsoft Visual Studio 11.0\\Common7\\IDE\\ProjectTemplates\\CSharp\\Web\\1033

VS 2012 Express

C:\\Program Files (x86)\\Microsoft Visual Studio 11.0\\Common7\\IDE\\VWDExpress\\ProjectTemplates\\CSharp\\Web\\1033

I ended up reformatting my machine (before realizing they were using different versions) but this time I installed VS 2012 PRO first and then VS 2012 Express however, I had the same issue. So I copied the *ProjectTemplatev4.1.cshtml files to

C:\\Program Files (x86)\\Microsoft Visual Studio 11.0\\Common7\\IDE\\VWDExpress\\ProjectTemplates\\CSharp\\Web\\1033

and it fixed the problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM