简体   繁体   English

ASP.NET MVC 5和Visual Studio 2015RC CS0234和CS0103错误

[英]ASP.NET MVC 5 and Visual Studio 2015RC CS0234 and CS0103 errors

There are similar Qs on SO but I could find none relating to my specifics 关于SO有类似的问题,但我找不到与我的细节有关的问题

The ASP.NET MVC file new project builds and runs ok but in the editor I have red squigglies all over the place with numerous CS0234: "the type or namespace 'MVC' does not exist" and CS0103: the name xxxx does not exist in the current context. ASP.NET MVC文件新项目将生成并正常运行,但是在编辑器中,我到处都是红色的弯弯曲曲,上面有许多CS0234:“类型或名称空间'MVC'不存在”和CS0103:名称xxxx在其中不存在当前上下文。 Where xxxx is ViewBag, Scripts, RenderSection etc. 其中xxxx是ViewBag,脚本,RenderSection等。

On adding a model and referencing items on that model using @Model then this too fails in the same way in the editor. 在添加模型并使用@Model引用该模型上的项目时,这同样会在编辑器中失败。 Opening existing projects from vs2013 in 2015 also behaves the same. 2015年从vs2013打开现有项目的行为也一样。 I can see local copies of System.Web.Helpers.dll and System.Web..Mvc.dll in the local bin directory but the editor cannot be referencing these. 我可以在本地bin目录中看到System.Web.Helpers.dll和System.Web..Mvc.dll的本地副本,但编辑器无法引用这些副本。

I have tried deleting and reinstalling MVC (Microsoft.AspNet.Mvc) manually using nuget to no avail. 我尝试使用nuget手动删除并重新安装MVC(Microsoft.AspNet.Mvc),但无济于事。

os: windows 8.1 pro 操作系统:Windows 8.1专业版

Maybe a known bug? 也许是已知的错误? Hope someone can throw some light on this. 希望有人可以对此有所启发。

Web Config (extract): Web配置(提取):

<dependentAssembly>
    <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
    <bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="3.0.0.0" />
  </dependentAssembly>
  <dependentAssembly>
    <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
    <bindingRedirect oldVersion="1.0.0.0-5.2.3.0" newVersion="5.2.3.0" />
  </dependentAssembly>
  <dependentAssembly>

Packages (extract): 包装(提取):

<packages>

  <package id="Microsoft.AspNet.Identity.Core" version="2.2.0" targetFramework="net452" userInstalled="true" />
  <package id="Microsoft.AspNet.Identity.EntityFramework" version="2.2.0" targetFramework="net452" userInstalled="true" />
  <package id="Microsoft.AspNet.Identity.Owin" version="2.2.0" targetFramework="net452" userInstalled="true" />
  <package id="Microsoft.AspNet.Mvc" version="5.2.3" targetFramework="net452" userInstalled="true" />
  <package id="Microsoft.AspNet.Razor" version="3.2.3" targetFramework="net452" userInstalled="true" />
  <package id="Microsoft.AspNet.Web.Optimization" version="1.1.3" targetFramework="net452" userInstalled="true" />
  <package id="Microsoft.AspNet.WebPages" version="3.2.3" targetFramework="net452" userInstalled="true" />

</packages>

Thought I had fixed this (see below faux fix 1 below) but the c# code completion/intellisense was still broken. 以为我已经解决了这个问题(请参见下面的人造补丁1),但是C#代码完成/智能感知仍被破坏。 Reinstalling VS made no difference. 重新安装VS没什么区别。

faux fix 1 squigglies + cs0234 errors disappeared but no c# intellisense/code completion 人工修复1弯曲+ cs0234错误消失但没有c#智能感知/代码完成

  1. went to programs and features to modify the current vs settings to remove just the web tools 转到程序和功能来修改当前vs设置,仅删除网络工具
  2. almost immediately aborted the above - the installer aborted with no changes except maybe setting a restore point. 几乎立即中止了以上操作-安装程序中止了,没有进行任何更改,只是可能设置了还原点。 Thought it was prudent to go back into vs and uninstall web essentials extension first! 认为先返回vs并卸载Web Essentials扩展是谨慎的做法!
  3. in vs uninstalled web essentials 与未安装的Web基本内容
  4. on restarting vs had an error relating to chutzpah extension ( error details below) which I uninstalled 关于重新启动与有与chutzpah扩展有关的错误(以下错误详细信息),我已卸载
  5. Opened vs again to check it still worked - newed up an asp.net mvc 5 project (so at this stage no changes have been made to the vs installed components) and everything was working no more errors in the editor all squigglies gone! 再次打开vs来检查它是否仍然有效-更新了一个asp.net mvc 5项目(因此在此阶段未对vs安装的组件进行任何更改),并且一切正常,编辑器中的错误不再消失了!
  6. reloaded above extensions and everything still works 重新加载了扩展,一切仍然有效

error details (from %APPDATA%\\Microsoft\\VisualStudio\\10.0\\ActivityLog.xml) 错误详细信息(来自%APPDATA%\\ Microsoft \\ VisualStudio \\ 10.0 \\ ActivityLog.xml)

<entry>
    <record>389</record>
    <time>2015/05/06 19:45:05.396</time>
    <type>Information</type>
    <source>VisualStudio</source>
    <description>Begin package load [ChutzpahVS2012Package]</description>
    <guid>{A523D775-1341-4F21-A950-8C716E5628C9}</guid>
  </entry>
  <entry>
    <record>390</record>
    <time>2015/05/06 19:45:05.396</time>
    <type>Error</type>
    <source>VisualStudio</source>
    <description>SetSite failed for package [ChutzpahVS2012Package]</description>
    <guid>{A523D775-1341-4F21-A950-8C716E5628C9}</guid>
    <hr>80070002</hr>
    <errorinfo>Could not load file or assembly 'Microsoft.VisualStudio.TestPlatform.ObjectModel, Version=11.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.</errorinfo>
  </entry>

end of faux fix 1 假修复1结束

More thorough uninstall followed by a manual clean up and finally a fresh install fixed the issue, steps I took were: 更彻底的卸载,然后进行手动清理,最后重新安装解决了该问题,我采取的步骤是:

  1. reset settings 重新设置
  2. uninstall updates and extensions 卸载更新和扩展
  3. uninstall vs - do not repair (check if ssdt tooling v 14.X has been removed from programs + features) 卸载vs-不修复(检查ssdt工具v 14.X是否已从程序和功能中删除)
  4. uninstall the Microsoft android emulator 卸载Microsoft android仿真器
  5. clean contents of: [documents]/visual studio 2015/Settings [文档] / Visual Studio 2015 / Settings的干净内容
  6. remove directory: C:\\Program Files (x86)\\Microsoft Visual Studio 14.0 删除目录:C:\\ Program Files(x86)\\ Microsoft Visual Studio 14.0
  7. clean-up android pieces - the installer uses its own copy of the android sdks which are not needed if you have an existing local install. 清理android片段-安装程序使用自己的android sdks副本,如果您已有本地安装,则不需要。 VS can be configured to use these. VS可以配置为使用这些。
  8. reinstall android emulator from C:\\ProgramData\\Microsoft\\VisualStudioSecondaryInstaller\\14.0\\installers \\VSEmu_Android\\5BB714E7FFD81CCD122D7489709480E863AE7999EB5C9AF862033F98B106DACB 从C:\\ ProgramData \\ Microsoft \\ VisualStudioSecondaryInstaller \\ 14.0 \\ installers \\ VSEmu_Android \\ 5BB714E7FFD81CCD122D7489709480E863AE7999EB5C9AF862033F98B106DACB重新安装Android模拟器

This felt like a sledge hammer to crack a very small nut! 感觉就像是一把大锤子,可以敲碎一个很小的螺母!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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