asp.net-mvc – 如何修复错误名称空间’System’中不存在类型或
发布时间:2020-12-16 04:28:01 所属栏目:asp.Net 来源:网络整理
导读:ASP.NET MVC4应用程序包含包含Razor帮助程序的App_Code文件夹中的Helper.chtml文件. 升级到Visual Studio Communitity版本后编译错误 Error CS0234 The type or namespace name 'Linq' does not exist in the namespace 'System' (are you missing an assemb
ASP.NET MVC4应用程序包含包含Razor帮助程序的App_Code文件夹中的Helper.chtml文件.
升级到Visual Studio Communitity版本后编译错误 Error CS0234 The type or namespace name 'Linq' does not exist in the namespace 'System' (are you missing an assembly reference?) C:UsersuserAppDataLocalTempTemporary ASP.NET Filesadmine209c0e0c74032baSources_App_Codehelper.cshtml.72cecc2a.cs 16 开始发生.生成的代码包含: namespace ASP { using System; using System.Collections.Generic; using System.IO; using System.Linq; // Error occurs in this line using System.Net; using System.Web; using System.Web.Helpers; using System.Web.Security; using System.Web.UI; using System.Web.WebPages; using System.Web.WebPages.Html; #line 1 "C:WebErpApp_CodeHelper.cshtml" using System.Web.Mvc; #line default #line hidden #line 2 "C:WebErpApp_CodeHelper.cshtml" using System.Threading; #line default #line hidden #line 3 "C:WebErpApp_CodeHelper.cshtml" using MyApp.Business; #line default #line hidden public class Helper : System.Web.WebPages.HelperPage { 错误指向使用System.Linq;线. 如何解决这个问题? 我尝试将System.Core的引用添加到项目中,但是已经引用了错误. <compilation debug="true"> </compilation> 我改成了 <compilation debug="true" targetFramework="4.0"> </compilation> 根据The type or namespace name ‘Linq’ does not exist in the namespace ‘System’和https://social.msdn.microsoft.com/Forums/en-US/c970ea3d-5238-4ec7-8859-e16b40dccd3d/the-type-or-namespace-name-linq-does-not-exist-in-the-namespace-systemare-you-missing-an?forum=linqprojectgeneral 但在那之后编译错误变为 Error CS0234 The type or namespace name 'global_asax' does not exist in the namespace 'ASP' (are you missing an assembly reference?) 这指向代码 protected static ASP.global_asax ApplicationInstance { get { return ((ASP.global_asax)(Context.ApplicationInstance)); } } 在生成的helper.cshtml.72cecc2a.cs文件中. 如何解决此错误? 更新 web.config的相关部分是: <?xml version="1.0" encoding="utf-8"?> <configuration> <system.data> <DbProviderFactories> <clear /> <add name="Npgsql Data Provider" invariant="Npgsql" support="FF" description=".Net Framework Data Provider for Postgresql Server" type="Npgsql.NpgsqlFactory,Npgsql" /> </DbProviderFactories> </system.data> <system.web> <httpModules> <remove name="RoleManager" /> </httpModules> <compilation debug="true"> </compilation> <customErrors mode="Off" /> <globalization uiCulture="auto" culture="auto" enableClientBasedCulture="true" /> <pages> <namespaces> <add namespace="MYApp.Business" /> <add namespace="System.Web.Helpers" /> <add namespace="System.Web.Mvc" /> <add namespace="System.Web.Mvc.Ajax" /> <add namespace="System.Web.Mvc.Html" /> <add namespace="System.Web.Routing" /> <add namespace="System.Web.Optimization" /> <add namespace="System.Web.WebPages" /> </namespaces> </pages> </system.web> <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-1.6.5135.21930" newVersion="1.6.5135.21930" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="Antlr3.Runtime" publicKeyToken="eb42632606e9261f" culture="neutral" /> <bindingRedirect oldVersion="0.0.0.0-3.5.0.2" newVersion="3.5.0.2" /> </dependentAssembly> </assemblyBinding> </runtime> </configuration> 解决方法
尝试在默认控制器中添加System.Linq命名空间.
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- asp.net – Mscaptcha在本地运行良好,但图片没有在服务器中
- asp.net core中使用EF Core自动生成表的Id主键
- asp.net – 在.NET 4.5 Azure部署中找不到编译器可执行文件
- asp.net-mvc – 将@ Html.RadioButtonFor设置为默认选中
- 利用ASP.netCore自带DI(DependencyInjection)实现批量依赖注
- asp.net开发中怎样去突破文件依赖缓存
- asp.net – 为什么这违反了类型约束?
- asp.net-web-api – HttpClient不报告从Web API返回的异常
- 从asp.net迁移到php
- 处理用户在ASP.NET MVC网站中点击“Enter”键
推荐文章
站长推荐
- asp.net – IIS 7.0和IIS 7.5之间有什么区别?
- asp.net – 如何在javascript中检测/跟踪回发?
- asp.net-core – 无法运行dnx控制台应用程序
- 如何使用ASP.net Web API和Javascript下载二进制
- asp.net-identity – AspNetCore – 使用Google身
- asp.net-mvc-3 – ASP.NET MVC 3编辑器模板中的I
- asp.net – 如何将HTML片段(作为委托?)传递给声
- .net – FormsAuthenticationModule是否检测到…
- ASP.NET自带对象JSON字符串与实体类的转换
- asp.net – 发布网站项目时Temp路径太长
热点阅读