2015-02-09 98 views
1

在win7上,我的应用程序正常工作。但是当我尝试在win8上运行这个时,我得到一个错误。无法加载文件或程序集'System.Web.WebPages.Razor,版本= 2.0.0.0,win8

无法加载文件或程序集“System.Web.WebPages.Razor, 版本= 2.0.0.0

System.Web.WebPages.Razor.dll是本地复制发布期间。 如果它很重要,那么前一段时间我会从mvc4迁移到mvc5。

堆栈跟踪:

[FileLoadException:未能加载文件或组件 'System.Web.WebPages.Razor,版本= 2.0.0.0,文化=中性 公钥= 31bf3856ad364e35' LUB jednejž jegozależności。 Zlokalizowana definicja manifestu zestawu nie odpowiadaodwołaniudo zestawu。 (WyjątekOD HRESULT:0x80131040)]
Microsoft.Web.WebPages.OAuth.PreApplicationStartCode.Start()0

[InvalidOperationException异常:Metoda开始瓦特typie Microsoft.Web.WebPages.OAuth.PreApplicationStartCode,wywoływana呐 etapie inicjalizacji przed uruchomieniem aplikacji,zgłosiławyjątek; komunikat obłędzie:Niemożnazaładowaćpliku lub zestawu 'System.Web.WebPages.Razor,Version = 2.0.0.0,Culture = neutral, PublicKeyToken = 31bf3856ad364e35'lub jednej z jegozależności。 Zlokalizowana definicja manifestu zestawu nie odpowiadaodwołaniudo zestawu。 (WyjątekOD HRESULT:0x80131040)。]
System.Web.Compilation.BuildManager.InvokePreStartInitMethodsCore(ICollection的1 methods, Func 1 setHostingEnvironmentCultures)12618627个
System.Web.Compilation.BuildManager.InvokePreStartInitMethods(ICollection`1 方法)12618348
System.Web.Compilation.BuildManager.CallPreStartInitMethods(字符串 preStartInitListPath,布尔& isRefAssemblyLoaded)280
System.Web.Compilation.BuildManager.ExecutePreAppStart()172
System.Web.Hosting.HostingEnvironment.Initialize(ApplicationManager AppManager的,IApplicationHost应用程序主机,IConfigMapPathFactory configMapPathFactory,HostingEnvironmentParameters hostingParameters, PolicyLevel policyLevel,异常appDomainCreationException)1151

[HttpException(0x80004005的):Metoda开始W¯¯typie Microsoft.Web.WebPages.OAuth.PreApplicationStartCode,wywoływana呐 etapie inicjalizacji przed uruchomieniem aplikacji,zgłosiławyjątek; komunikat obłędzie:Niemożnazaładowaćpliku lub zestawu 'System.Web.WebPages.Razor,Version = 2.0.0.0,Culture = neutral, PublicKeyToken = 31bf3856ad364e35'lub jednej z jegozależności。 Zlokalizowana definicja manifestu zestawu nie odpowiadaodwołaniudo zestawu。 (WyjątekOD HRESULT:0x80131040)。]
System.Web.HttpRuntime.FirstRequestInit(HttpContext的上下文)12617668 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext的上下文) 159 System.Web.HttpRuntime。ProcessRequestNotificationPrivate(IIS7WorkerRequest WR,HttpContext的上下文)124​​57285

根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

我得到这个有点沙找到如果我等待约30秒,并刷新它消失,你有没有试过这个? – JMK 2015-02-09 10:53:49

+0

发生Dll版本冲突。 – 2015-02-09 10:56:08

+0

卸载Microsoft.AspNet.Mvc并重新安装。然后重建项目。 – CodingDefined 2015-02-09 10:58:22

回答

0

问题解决了。

我更新

Microsoft.Web.WebPages.OAuth 

感谢所有帮助

0

其实,出现问题时,你更新的NuGet包或任何东西。由于更新发生在程序包/ dll中,因此相应版本应包含在网络配置中。不幸的是,它不反映在Web配置导致上述错误导致的.dll文件版本和Web配置版本冲突。

解决方案:

步骤1:转到项目解Explorer的>参考 - > System.Web.WebPages.Razor(任何附图投掷错误)

步骤2:右键单单击 - >属性

步骤3:在性能,你会发现版本:XXXX(3.0.0.0 2.0.0.0或) 这个版n是项目中加载的实际版本。

第4步:现在,转到Web.config文件(在Web视图文件夹中的Web配置) 找到System.Web.WebPages.Razor,Version = X.X.X.X行。 然后,将版本号更改为版本号,您可以在步骤3的参考属性中找到该版本号。

现在,运行代码问题应该消失。

相关问题