And*_*rus 9 asp.net-mvc visual-studio razor razor-declarative-helpers asp.net-mvc-4
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:\Users\user\AppData\Local\Temp\Temporary ASP.NET Files\admin\e209c0e0\c74032ba\Sources_App_Code\helper.cshtml.72cecc2a.cs 16
Run Code Online (Sandbox Code Playgroud)
开始发生.生成的代码包含:
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:\Web\Erp\App_Code\Helper.cshtml"
using System.Web.Mvc;
#line default
#line hidden
#line 2 "C:\Web\Erp\App_Code\Helper.cshtml"
using System.Threading;
#line default
#line hidden
#line 3 "C:\Web\Erp\App_Code\Helper.cshtml"
using MyApp.Business;
#line default
#line hidden
public class Helper : System.Web.WebPages.HelperPage {
Run Code Online (Sandbox Code Playgroud)
错误指向using System.Linq;
行.
如何解决这个问题?使用ASP.NET4
我试图将System.Core的引用添加到项目中,但是已经引用了错误.web.confing包含
<compilation debug="true">
</compilation>
Run Code Online (Sandbox Code Playgroud)
我改成了
<compilation debug="true" targetFramework="4.0">
</compilation>
Run Code Online (Sandbox Code Playgroud)
根据 类型或命名空间名称'Linq'在名称空间'System'和 https://social.msdn.microsoft.com/Forums/en-US/c970ea3d-5238-4ec7-8859-e16b40dccd3d/the-type 中不存在-或命名空间名称的LINQ不-不存在-在最命名空间systemare,你缺失安?论坛= linqprojectgeneral
但之后编译错误改为
Error CS0234 The type or namespace name 'global_asax' does not exist in the namespace 'ASP' (are you missing an assembly reference?)
Run Code Online (Sandbox Code Playgroud)
这指向代码
protected static ASP.global_asax ApplicationInstance {
get {
return ((ASP.global_asax)(Context.ApplicationInstance));
}
}
Run Code Online (Sandbox Code Playgroud)
在生成的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>
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
3644 次 |
最近记录: |