[英]Red lines under ViewBag and HTML.TextboxFor helpers in Views
I have installed Visual Studio 2012 that comes with MVC4, and opened a project done in MVC3.我已经安装了 MVC4 附带的 Visual Studio 2012,并打开了一个在 MVC3 中完成的项目。
On my views, all references to:在我看来,所有引用:
ViewBag.<Property>
Showed the red waved lines, saying "dynamic library missing", and显示红色波浪线,说“动态库丢失”,以及
HTML.TextBoxFor(m => m.Property)
HTML.HiddenFor(m => m.Property)
etc...
Showed error "arguments cannot be inferred from usage".显示错误“无法从用法推断参数”。
I found the answered in other no-related thread, so I'm opening this question here to help others, as I didn't find it in Google looking for the main topic.我在其他不相关的线程中找到了答案,所以我在这里打开这个问题来帮助其他人,因为我没有在谷歌中找到它寻找主要主题。 Below the answer.答案在下。
I tried troubleshooting this similar issue for hours.我尝试了几个小时来解决这个类似的问题。 Red lines under all @Html helpers.所有@Html 助手下的红线。 Everything I read on SOF and other sites would not work.我在 SOF 和其他网站上阅读的所有内容都不起作用。 The web app would compile and run fine. Web 应用程序将编译并运行良好。
The way I fixed my issue was by uploading all my code to my Visual Studio Online environment.我解决问题的方法是将所有代码上传到我的 Visual Studio Online 环境。 Delete the project folder/solution on my local machine.删除我本地机器上的项目文件夹/解决方案。 Close Visual Studio.关闭 Visual Studio。 Open Visual Studio.打开 Visual Studio。 Connect to team explorer and do a get latest from the source control explorer.连接到团队资源管理器并从源代码管理资源管理器获取最新信息。
Finally, go to File > Open > Project within VS and open the project .sln file.最后,在 VS 中转到 File > Open > Project 并打开项目 .sln 文件。
All the red lines and visual studio cache/temp files are cleaned up.所有红线和 Visual Studio 缓存/临时文件都已清除。
Here is the answer:这是答案:
In your Web.Config file make sure that the compilation target framework matches the httpRuntime target framework version eg:在您的 Web.Config 文件中,确保编译目标框架与 httpRuntime 目标框架版本匹配,例如:
<system.web>
<authentication mode="None"/>
<compilation debug="true" targetFramework="4.6.1"/>
<httpRuntime targetFramework="4.6.1"/>
<httpModules>
<add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web"/>
</httpModules>
</system.web>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.