Mir*_*ano 12 asp.net-mvc binding redirect azure .net-assembly
我正在尝试在Azure上部署测试Web应用程序,但是当我在本地计算机上运行Azure模拟器时,我从附加到我的WebRole的Azure模拟器控制台中收到此错误:
System.TypeLoadException: Unable to load the role entry point due to the following exceptions:
-- System.IO.FileLoadException: Could not load file or assembly 'System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
File name: 'System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'
=== Pre-bind state information ===
LOG: User = COLLAB\mirko.lugano
LOG: DisplayName = System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
(Fully-specified)
LOG: Appbase = file:///C:/Code/Application/<MyWebProject>.Azure/csx/Debug/roles/<MyWebProject>/approot/bin
LOG: Initial PrivatePath = C:\Code\Application\<MyWebProject>.Azure\csx\Debug\roles\<MyWebProject>\approot\bin
Calling assembly : ActionMailer.Net.Mvc, Version=0.7.4.0, Culture=neutral, PublicKeyToken=e62db3114c02a1c2.
===
LOG: This bind starts in default load context.
LOG: Using application configuration file: C:\Code\Application\<MyWebProject>.Azure\csx\Debug\roles\<MyWebProject>\base\x64\WaIISHost.exe.Config
LOG: Using host configuration file:
LOG: Using machine configuration file from C:\Windows\Microsoft.NET\Framework64\v4.0.30319\config\machine.config.
LOG: Post-policy reference: System.Web.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
LOG: Attempting download of new URL file:///C:/Code/Application/<MyWebProject>.Azure/csx/Debug/roles/<MyWebProject>/approot/bin/System.Web.Mvc.DLL.
WRN: Comparing the assembly name resulted in the mismatch: Major Version
ERR: Failed to complete setup of assembly (hr = 0x80131040). Probing terminated.
---> System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.
at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)
at System.Reflection.RuntimeModule.GetTypes()
at System.Reflection.Assembly.GetTypes()
at Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.GetRoleEntryPoint(Assembly entryPointAssembly)
--- End of inner exception stack trace ---
at Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.GetRoleEntryPoint(Assembly entryPointAssembly)
at Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.CreateRoleEntryPoint(RoleType roleTypeEnum)
at Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.InitializeRoleInternal(RoleType roleTypeEnum)
[fabric] Role state Unknown
Run Code Online (Sandbox Code Playgroud)
只要我在我的本地机器上安装了MVC3(MVC3程序集在GAC中),一切都运行良好,但是由于我删除了MVC3(Azure没有安装MVC),我收到了这个错误.我的网络应用程序定期包含MVC4,工作正常.然后我想到了程序集绑定重定向,我注意到在我的web.config文件中我已经有了:
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
...
<dependentAssembly>
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" />
</dependentAssembly>
...
</assemblyBinding>
</runtime>
Run Code Online (Sandbox Code Playgroud)
根据我在互联网上阅读的文档,这应该是正确的.我也尝试将my (版本4.0.0.0)的SpecificVersion属性设置为false但无效.我错过了什么吗?调用程序集是否应该自动重定向到正确版本的MVC程序集?任何想法都非常感谢.谢谢.System.Web.Mvc.dllActionMailer.Net.Mvc
Run*_*sen 10
在Azure WebRoles中,默认情况下(在完全IIS模式下),RoleEntryPoint会从WebRole的其余部分中脱离出来,并在不同的进程中运行.
这样做的副作用是您的RoleEntryPoint将无法访问您的web.config.
Azure SDK 1.3 -1.7将在WaIISHost.exe.config中查找
Azure SDK 1.8+将在WebRoleProjectName.dll.config中查找.
通过对SDK的最新更改,您应该能够在项目中放置app.config,然后您的角色入口点应该可以访问它.
您可以在此Microsoft 博客文章或此Stackoverflow帖子中阅读有关此内容的更多信息
| 归档时间: |
|
| 查看次数: |
5859 次 |
| 最近记录: |