1

将新的 MVC 3 Web 应用程序部署到 Azure 时出现错误。尽管该站点似乎可以正常工作,但存在角色初始化错误,这意味着 VS2010 的部署永远不会完成。(见下面的输出。)

我怀疑 Mindscape.Lightspeed.Web 程序集依赖于 MVC 2。但我认为以下配置部分会覆盖它。

  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />
        <bindingRedirect oldVersion="1.0.0.0-2.0.0.0" newVersion="3.0.0.0" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>

您可以通过从开发系统中卸载 MVC 2 然后在开发结构中运行来使用 Azure 项目来模拟这一点。

我怎样才能解决这个问题?

Microsoft.WindowsAzure.ServiceRuntime Critical: 201 : 'iisexpress.exe' (Managed (v4.0.30319)): Loaded 'C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\1001b7f1\d3c78bbf\assembly\dl3\d2532ce7\a08fd830_9d4bcd01\Microsoft.WindowsAzure.Configuration.DLL'
Role entrypoint could not be created:
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=2.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=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'

=== Pre-bind state information ===
LOG: User = DiscoveryOne\scott
LOG: DisplayName = System.Web.Mvc, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
 (Fully-specified)
LOG: Appbase = file:///C:/Users/scott/Documents/Visual Studio 2010/Projects/Teto.Azure/Teto.Azure/csx/Debug/roles/Teto.Web/approot/bin
LOG: Initial PrivatePath = C:\Users\scott\Documents\Visual Studio 2010\Projects\Teto.Azure\Teto.Azure\csx\Debug\roles\Teto.Web\approot\bin
Calling assembly : Mindscape.LightSpeed.Web, Version=4.0.1351.20441, Culture=neutral, PublicKeyToken=360c8f37b466ebb2.
===
LOG: This bind starts in default load context.
LOG: No application configuration file found.
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=2.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35
LOG: Attempting download of new URL file:///C:/Users/scott/Documents/Visual Studio 2010/Projects/Teto.Azure/Teto.Azure/csx/Debug/roles/Teto.Web/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.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)
The program '[1564] WaIISHost.exe: Program Trace' has exited with code 0 (0x0).
The program '[1564] WaIISHost.exe: Managed (v4.0.30319)' has exited with code -1 (0xffffffff).
4

2 回答 2

2

程序集重定向应该没问题,但不要忘记您可能需要在多个文件中配置它:

  • 网页配置
  • 视图\Web.config
  • WaIISHost.exe.config

您需要确保修改这两个 Web.config 文件。如果您从WebRole.cs文件调用 LightSpeed 程序集,我建议您创建一个名为WeIISHost.exe.config的新文件,添加重定向并将其复制到输出目录设置为始终。这是必需的,因为 WebRole 现在使用完整的 IIS

在此处输入图像描述

于 2012-06-24T09:39:52.833 回答
1

您是否检查以确保 Lightspeed 配置为在部分信任模式下运行?

http://www.mindscapehq.com/blog/index.php/2010/01/13/the-dynamic-duo-lightspeed-azure

于 2012-06-24T09:19:06.760 回答