asp.net – aspnet_compiler找到错误版本的System.Web.WebPages
发布时间:2020-12-15 22:15:41 所属栏目:asp.Net 来源:网络整理
导读:我有一个ASP.NET MVC4项目,编译精细VS2010。为了部署目的,我运行一个Nant脚本,试图使用aspnet_compiler.exe预编译网站,但我一直运行到一个程序集引用问题与System.Web.WebPage error CS1705: Assembly ‘System.Web.Mvc,Version=4.0.0.0,Culture=neutral
我有一个ASP.NET MVC4项目,编译精细VS2010。为了部署目的,我运行一个Nant脚本,试图使用aspnet_compiler.exe预编译网站,但我一直运行到一个程序集引用问题与System.Web.WebPage
我还在我的web.config中有以下程序集绑定: <runtime> <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> <dependentAssembly> <assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" /> <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="2.0.0.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" /> <bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" /> <bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" /> </dependentAssembly> <dependentAssembly> <assemblyIdentity name="System.Web.WebPages.Razor" publicKeyToken="31bf3856ad364e35" /> <bindingRedirect oldVersion="0.0.0.0-2.0.0.0" newVersion="2.0.0.0" /> </dependentAssembly> </assemblyBinding> </runtime> 和我的csproj有以下参考: <Reference Include="System.Web.WebPages,PublicKeyToken=31bf3856ad364e35"> <Private>True</Private> <HintPath>..packagesAspNetWebPages.Core.2.0.20126.16343libnet40System.Web.WebPages.dll</HintPath> </Reference> 解决方法
我通过在Web.config中明确引用2.0程序集来解决这个问题。我想由于某种原因,ASP.NET编译器(在我的情况下,当运行MvcBuildViews),使用旧的1.0程序集,如果找到。
<?xml version="1.0" encoding="utf-8"?> <configuration> <!-- … --> <system.web> <!-- … --> <compilation debug="true" targetFramework="4.0"> <assemblies> <add assembly="System.Web.Mvc,PublicKeyToken=31bf3856ad364e35,processorArchitecture=MSIL" /> <add assembly="System.Web.Abstractions,PublicKeyToken=31BF3856AD364E35" /> <add assembly="System.Web.Routing,PublicKeyToken=31BF3856AD364E35" /> <add assembly="System.Web.WebPages,processorArchitecture=MSIL" /> </assemblies> </compilation> <!-- … --> </system.web> <!-- … --> </configuration> BTW:看起来这个问题发生在我第一次添加第三方ASP.NET MVC 3.0组件后。该组件通过程序集绑定工作正常,但它可能是为什么ASP.NET编译器尝试首先加载1.0网页的原因。 (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |
相关内容
- 在razorview中显示checkboxfor的文本
- asp.net-mvc – 在哪里可以找到与asp.net MVC一起使用的优秀
- 以编程方式或声明性地要求IIS中的单个asp.net页面的客户端证
- asp.net-mvc – Angular 2:如何在不使用路由的情况下从URL
- Asp.Net Core 进阶(一) —— 读取appsettings.json
- asp.net-mvc – 如何使用ASP.NET身份(OWIN)访问Facebook的私
- 为什么默认的ASP.NET Forms认证Cookie在其默认名称=>“.ASP
- 单元测试 – 如何在MVC 6中存根/模拟AuthenticationManager
- exception throw in progress runner thread_VS2015中SVN源
- 如何删除IIS / ASP.NET响应标头