集绑定重定向不工作

集绑定重定向不工作

本文介绍了集绑定重定向不工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图部署在Azure上测试Web应用程序,但是当我在我的本地计算机上运行在Azure模拟器我从贴在我的WebRole在Azure模拟器控制台这个错误:

I am trying to deploy a test web app on Azure, but when I run the Azure emulator on my local machine I get this error from the Azure emulator console attached to my WebRole:

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

每一件东西都是只要我有我的本地机器上安装MVC3工作正常(在MVC3装配在GAC),但由于我删除MVC3(天青没有安装MVC),我收到此错误。我的web应用程序有MVC4包括定期和正常工作。然后,我曾想过集绑定重定向,我注意到,在我的web.config文件我已经有:

Everything had been working fine as long as I had MVC3 installed on my local machine (the MVC3 assembly was in GAC), but since I removed MVC3 (Azure has no MVC installed), I am getting this error. My web app has MVC4 regularly included and that works fine. I had then thought about assembly binding redirection, and I noticed that in my web.config file I already have:

  <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>

这应该已经是正确的,根据我在网上阅读周围的文档。我也曾尝试设置的 SpecificVersion 的财产我 System.Web.Mvc.dll程序版本4.0.0.0 的)为,但无济于事。我缺少的东西吗?不应该调用程序集 ActionMailer.Net.Mvc 被自动重定向到MVC组件的正确版本?任何想法是极大的AP preciated。谢谢你。

which should be already correct, according to the documentation I have read around in internet. I have also tried setting the SpecificVersion property of my System.Web.Mvc.dll (version 4.0.0.0) to false but to no avail. Am I missing something? Shouldn't the calling assembly ActionMailer.Net.Mvc be automatically redirected to the correct version of the MVC assembly? Any ideas are greatly appreciated. Thanks.

推荐答案

在Azure中WebRoles,默认情况下(在完整的IIS模式)RoleEntryPoint被从WebRole其余墙隔开了,并且在不同的进程运行。

In Azure WebRoles, by default (in Full IIS Mode) the RoleEntryPoint gets walled off from the rest of the WebRole, and runs in a different process.

这样做的副作用是,你RoleEntryPoint将无法访问您的的web.config

A side effect of this is that your RoleEntryPoint will not have access to your web.config.


  • 的Azure SDK 1.3 -1.7会看在 WaIISHost.exe.config

的Azure SDK 1.8+会看在 WebRoleProjectName.dll.config

Azure SDK 1.8+ will look in the WebRoleProjectName.dll.config.

通过最新的改变SDK,您应该能够放置的的app.config 的在您的项目和作用的切入点,然后应该有访问它。

With the newest change to the SDK, you should be able to place an app.config in your project and your role entry point should then have access to it.

您可以在此Microsoft blog张贴或在这个

You can read more about this in this Microsoft blog post or in this Stackoverflow post

这篇关于集绑定重定向不工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-15 20:02