将MVC网站部署到Azure

时间:2012-06-24 08:46:58

标签: asp.net-mvc asp.net-mvc-3 deployment azure

当我将新的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).

2 个答案:

答案 0 :(得分:1)

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

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

答案 1 :(得分:1)

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

  • 的Web.config
  • 视图\的Web.config
  • WaIISHost.exe.config

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

enter image description here