【Azure Cloud Service】部署云服务时候遇见 Last exit code: 0. Last role exception: (System.IO.FileNotFoundException) 错误 - LuBu0505/My-Code GitHub Wiki

问题描述

部署云服务时候遇见 Last exit code: 0. Last role exception: (System.IO.FileNotFoundException) 错误,提示无法加载System.Runtime。

Recovering role... Application startup task 0 finished successfully. 
Last exit time: [2024/03/27, 20:23:31.142]. Last exit code: 0. Last role exception: (System.IO.FileNotFoundException)|>Process ID: 221 Process Name: WaIISHost

Thread ID: 1 AppDomain Unhandled Exception for role WebApiWebRole_IN_0

Exception: Could not load file or assembly 'System.Runtime, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.

   at WebApiWebRole.WebRole.OnStart()

   at Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.InitializeRoleInternal(RoleType roleTypeEnum)

   at Microsoft.WindowsAzure.ServiceRuntime.Implementation.Loader.RoleRuntimeBridge.<InitializeRole>b__0()

   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)

   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)

   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)

   at System.Threading.ThreadHelper.ThreadStart()

问题解答

原因 2:DLL 或程序集缺失

(Source: https://learn.microsoft.com/zh-cn/troubleshoot/azure/cloud-services/extended/role-startup-failure#cause-2-dlls-or-assemblies-are-missing)

无响应的角色实例和在状态之间循环的角色实例可能是由于缺少 DLL 或程序集而导致的。

下面是缺少 DLL 或程序集的一些症状:

  • 角色实例将循环访问 “正在初始化”、“ 忙碌”和 “正在停止” 状态。

  • 角色实例已移至 “就绪” 状态,但页面在 Web 应用程序中不可见。

根据云服务的排查 " ***DLL 或程序集缺失 *** " 的文档,排查没有Dll遗漏,所以还是没有解决此问题。 image.png 最后,把启动项变更为 webRole 后,部署成功。但确实没有道理,因为Project中的启动项设置与打包后的部署文件并没有关系。

PS: 。。。 一直在困惑中 。。。

参考资料

排查 Azure 云服务中的角色实例启动失败问题  : https://learn.microsoft.com/zh-cn/troubleshoot/azure/cloud-services/extended/role-startup-failure#cause-2-dlls-or-assemblies-are-missing

当在复杂的环境中面临问题,格物之道需:浊而静之徐清,安以动之徐生。 云中,恰是如此!