在win7上我的应用程序正常工作。但是当我尝试在win8上运行时,我得到一个错误。
无法加载文件或程序集'System.Web.WebPages.Razor, 版本= 2.0.0.0
System.Web.WebPages.Razor.dll在发布期间是本地复制。 如果它很重要,我会在不久前从mvc4迁移到mvc5。
堆栈追踪:
[FileLoadException:无法加载文件或程序集 'System.Web.WebPages.Razor,Version = 2.0.0.0,Culture = neutral, PublicKeyToken = 31bf3856ad364e35'lub jednej zjegozależności。 Zlokalizowana definicja manifestu zestawu nieodpowiadodowołaniudo zestawu。 (WyjątekodHRESULT:0x80131040)]
Microsoft.Web.WebPages.OAuth.PreApplicationStartCode.Start()+ 0[InvalidOperationException:Metoda Start w typie Microsoft.Web.WebPages.OAuth.PreApplicationStartCode,wywoływanana etapie inicjalizacji przed uruchomieniem aplikacji,zgłosiławyjątek; komunikatobłędzie:Niemożnazaładowaćplikulub zestawu 'System.Web.WebPages.Razor,Version = 2.0.0.0,Culture = neutral, PublicKeyToken = 31bf3856ad364e35'lub jednej zjegozależności。 Zlokalizowana definicja manifestu zestawu nieodpowiadodowołaniudo zestawu。 (WyjątekodHRESULT:0x80131040)。]
System.Web.Compilation.BuildManager.InvokePreStartInitMethodsCore(ICollection1 methods, Func
1 setHostingEnvironmentCultures)+12618627
System.Web.Compilation.BuildManager.InvokePreStartInitMethods(ICollection`1 方法)+12618348
System.Web.Compilation.BuildManager.CallPreStartInitMethods(字符串 preStartInitListPath,Boolean& isRefAssemblyLoaded)+280
System.Web.Compilation.BuildManager.ExecutePreAppStart()+172
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager appManager,IApplicationHost appHost,IConfigMapPathFactory configMapPathFactory,HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel,Exception appDomainCreationException)+1151[HttpException(0x80004005):Metoda Start w typie Microsoft.Web.WebPages.OAuth.PreApplicationStartCode,wywoływanana etapie inicjalizacji przed uruchomieniem aplikacji,zgłosiławyjątek; komunikatobłędzie:Niemożnazaładowaćplikulub zestawu 'System.Web.WebPages.Razor,Version = 2.0.0.0,Culture = neutral, PublicKeyToken = 31bf3856ad364e35'lub jednej zjegozależności。 Zlokalizowana definicja manifestu zestawu nieodpowiadodowołaniudo zestawu。 (WyjątekodHRESULT:0x80131040)。]
System.Web.HttpRuntime.FirstRequestInit(HttpContext context)+12617668 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +159 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest) wr,HttpContext context)+12457285
root Web.config
<?xml version="1.0" encoding="utf-8"?>
<!--
For more information on how to configure your ASP.NET application, please visit
http://go.microsoft.com/fwlink/?LinkId=152368
-->
<configuration>
<configSections>
<!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 -->
<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=5.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />
<section name="aprSection" type="APRLibrary.Configuration.APRWebSectionWithBaseLogin, APRLibrary" />
</configSections>
<aprSection configSource="APRTeam.config" />
<appSettings>
<add key="webpages:Version" value="3.0.0.0" />
<add key="webpages:Enabled" value="true" />
<add key="PreserveLoginUrl" value="true" />
<add key="ClientValidationEnabled" value="true" />
<add key="UnobtrusiveJavaScriptEnabled" value="true" />
<add key="aspnet:MaxJsonDeserializerMembers" value="150000" />
</appSettings>
<!--
For a description of web.config changes see http://go.microsoft.com/fwlink/?LinkId=235367.
The following attributes can be set on the <httpRuntime> tag.
<system.Web>
<httpRuntime targetFramework="4.5.1"/>
</system.Web>
-->
<system.web>
<compilation debug="true" targetFramework="4.5.1">
<assemblies>
<add assembly="System.Web.Mvc, Version=5.2.2.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
</assemblies>
</compilation>
<httpRuntime targetFramework="4.5" maxQueryStringLength="6048" encoderType="System.Web.Security.AntiXss.AntiXssEncoder, System.Web, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
<machineKey compatibilityMode="Framework45" />
<customErrors mode="Off" defaultRedirect="~/Error.cshtml">
<error statusCode="500" redirect="~/Error.cshtml"/>
<error statusCode="403" redirect="~/error?status=403"/>
<error statusCode="404" redirect="~/error?status=404"/>
</customErrors>
<pages>
<namespaces>
<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.WebPages" />
<add namespace="Kendo.Mvc.UI" />
<add namespace="APRTeamGrafikMVC4.Code.Helpers" />
</namespaces>
</pages>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<modules runAllManagedModulesForAllRequests="true" />
<handlers>
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" />
<remove name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" />
<remove name="ExtensionlessUrlHandler-Integrated-4.0" />
<add name="ExtensionlessUrlHandler-ISAPI-4.0_32bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness32" responseBufferLimit="0" />
<add name="ExtensionlessUrlHandler-ISAPI-4.0_64bit" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" modules="IsapiModule" scriptProcessor="%windir%\Microsoft.NET\Framework64\v4.0.30319\aspnet_isapi.dll" preCondition="classicMode,runtimeVersionv4.0,bitness64" responseBufferLimit="0" />
<add name="ExtensionlessUrlHandler-Integrated-4.0" path="*." verb="GET,HEAD,POST,DEBUG,PUT,DELETE,PATCH,OPTIONS" type="System.Web.Handlers.TransferRequestHandler" preCondition="integratedMode,runtimeVersionv4.0" />
</handlers>
<security>
<requestFiltering>
<requestLimits maxQueryString="6048" />
</requestFiltering>
</security>
</system.webServer>
<entityFramework>
<defaultConnectionFactory type="System.Data.Entity.Infrastructure.SqlConnectionFactory, EntityFramework" />
</entityFramework>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="DotNetOpenAuth.AspNet" publicKeyToken="2780ccd10d57b246" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="DotNetOpenAuth.Core" publicKeyToken="2780ccd10d57b246" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.1.0.0" newVersion="4.1.0.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="WebGrease" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-1.3.0.0" newVersion="1.3.0.0" />
</dependentAssembly>
<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.WebPages" 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.2.0" newVersion="5.2.2.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
</configuration>
观看web.config
<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="system.web.webPages.razor" type="System.Web.WebPages.Razor.Configuration.RazorWebSectionGroup, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<section name="host" type="System.Web.WebPages.Razor.Configuration.HostSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
<section name="pages" type="System.Web.WebPages.Razor.Configuration.RazorPagesSection, System.Web.WebPages.Razor, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" requirePermission="false" />
</sectionGroup>
</configSections>
<system.web.webPages.razor>
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=5.2.2.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<pages pageBaseType="System.Web.Mvc.WebViewPage">
<namespaces>
<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="Kendo.Mvc.UI" />
</namespaces>
</pages>
</system.web.webPages.razor>
<appSettings>
<add key="webpages:Enabled" value="false" />
</appSettings>
<system.web>
<httpHandlers>
<add path="*" verb="*" type="System.Web.HttpNotFoundHandler" />
</httpHandlers>
<!--
Enabling request validation in view pages would cause validation to occur
after the input has already been processed by the controller. By default
MVC performs request validation before a controller processes the input.
To change this behavior apply the ValidateInputAttribute to a
controller or action.
-->
<pages validateRequest="false" pageParserFilterType="System.Web.Mvc.ViewTypeParserFilter, System.Web.Mvc, Version=5.2.2.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" pageBaseType="System.Web.Mvc.ViewPage, System.Web.Mvc, Version=5.2.2.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" userControlBaseType="System.Web.Mvc.ViewUserControl, System.Web.Mvc, Version=5.2.2.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<controls>
<add assembly="System.Web.Mvc, Version=5.2.2.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" namespace="System.Web.Mvc" tagPrefix="mvc" />
</controls>
</pages>
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false" />
<handlers>
<remove name="BlockViewHandler" />
<add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler" />
</handlers>
</system.webServer>
</configuration>
答案 0 :(得分:0)
问题解决了。
我更新
Microsoft.Web.WebPages.OAuth
感谢您的帮助
答案 1 :(得分:0)
实际上,当您更新 NuGet 包或其他内容时,会出现问题。由于更新发生在package / dll中,相应的版本更新应包含在 web config 中。不幸的是,它没有反映在Web配置上导致.dll文件版本和Web配置版本冲突导致上述错误。
解决方案:
第1步:转到项目解决方案资源管理器 - &gt;参考 - &gt; System.Web.WebPages.Razor(任何引用抛出错误)
第2步:右击 - &gt;特性强>
步骤3:在属性中,您会找到版本:X.X.X.X (3.0.0.0或2.0.0.0) 此版本是项目中加载的实际版本。
步骤4:现在,转到Web.config文件(Views文件夹中的Web配置) 找到System.Web.WebPages.Razor,Version = X.X.X.X行。 然后,将版本更改为您在步骤3 中的参考属性中找到的版本号。
现在,运行代码问题应该消失。