Azure 工作者角色投掷 System.IO.FileNotFoundException

Azure worker role throwing System.IO.FileNotFoundException

我重新部署了一个可操作的 Azure 工作者角色,并进行了一些更改,其中涉及引用我已经设置的新 class 库项目,并开始无休止地看到工作者角色 reboot/recycle。

事件查看器应用程序日志提供的帮助非常少,因为我收到的错误非常普遍。

来源:.NET 运行时

Application: WaWorkerHost.exe Framework Version: v4.0.30319 Description: The process was terminated due to an unhandled exception. Exception Info: System.IO.FileNotFoundException Stack: at System.ModuleHandle.ResolveType(System.Reflection.RuntimeModule, Int32, IntPtr*, Int32, IntPtr*, Int32, System.Runtime.CompilerServices.ObjectHandleOnStack) at System.ModuleHandle.ResolveType(System.Reflection.RuntimeModule, Int32, IntPtr*, Int32, IntPtr*, Int32, System.Runtime.CompilerServices.ObjectHandleOnStack) at System.ModuleHandle.ResolveTypeHandleInternal(System.Reflection.RuntimeModule, Int32, System.RuntimeTypeHandle[], System.RuntimeTypeHandle[]) at System.ModuleHandle.ResolveTypeHandle(Int32, System.RuntimeTypeHandle[], System.RuntimeTypeHandle[]) at System.Reflection.RuntimeModule.ResolveType(Int32, System.Type[], System.Type[]) at System.Reflection.CustomAttribute.FilterCustomAttributeRecord(System.Reflection.CustomAttributeRecord, System.Reflection.MetadataImport, System.Reflection.Assembly ByRef, System.Reflection.RuntimeModule, System.Reflection.MetadataToken, System.RuntimeType, Boolean, System.Object[], System.Collections.IList, System.RuntimeType ByRef, System.IRuntimeMethodInfo ByRef, Boolean ByRef, Boolean ByRef) at System.Reflection.CustomAttribute.GetCustomAttributes(System.Reflection.RuntimeModule, Int32, Int32, System.RuntimeType, Boolean, System.Collections.IList, Boolean) at System.Reflection.CustomAttribute.GetCustomAttributes(System.Reflection.RuntimeAssembly, System.RuntimeType) at Microsoft.WindowsAzure.Hosts.Worker.Loader.CreateConsoleRole(Microsoft.WindowsAzure.Hosts.Worker.Parameters) at Microsoft.WindowsAzure.Hosts.Worker.Loader.Main(System.String[])

来源:应用程序错误

Faulting application name: WaWorkerHost.exe, version: 2.7.1198.768, time stamp: 0x57159090 Faulting module name: KERNELBASE.dll, version: 6.3.9600.18340, time stamp: 0x57366075 Exception code: 0xe0434352 Fault offset: 0x0000000000008a5c Faulting process id: 0xf20 Faulting application start time: 0x01d287c5480b416f Faulting application path: E:\base\x64\WaWorkerHost.exe Faulting module path: D:\Windows\system32\KERNELBASE.dll Report Id: 85f9c3f7-f3b8-11e6-80c1-0004ff9da18e Faulting package full name: Faulting package-relative application ID:

我搜索过这个,但没有遇到任何人收到像这样一般的错误消息。

我自己的日志记录也没有提供太多见解。我所知道的是 WorkerRole 没有命中 OnStart 方法。

是否有任何其他日志可以帮助缩小问题范围?

提前致谢。

想通了...但不是最优雅的方式。

我继续更新了来自 Nuget 的所有 DLL 以用于辅助角色和 class 库项目。那里的东西解决了那个问题(我知道,不好吧?)但后来我遇到了另一个问题:

Application: WaWorkerHost.exe Framework Version: v4.0.30319 Description: The process was terminated due to an unhandled exception. Exception Info: System.TypeInitializationException Stack: at Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.Initialize() at Microsoft.WindowsAzure.ServiceRuntime.Implementation.Loader.RoleRuntimeBridge.Initialize(String[] args) at Microsoft.WindowsAzure.ServiceRuntime.Implementation.Loader.RoleRuntimeBridge.Initialize(System.String[]) at Microsoft.WindowsAzure.Hosts.Worker.Loader.CreateConsoleRole(Microsoft.WindowsAzure.Hosts.Worker.Parameters) at Microsoft.WindowsAzure.Hosts.Worker.Loader.Main(System.String[])

为了解决这个问题,我最终偶然发现了 here, which led me to this。我在辅助角色 VM 上下载了 AzureTools,并将调试器附加到回收 WaWorkerHost 进程。以下是上述link的相关摘录:

AzureTools includes an option under the Utils tab to attach a debugger to the startup of a process. Switch to the Utils tab, click Attach Debugger, select WaIISHost from the process list, then click Attach Debugger. You will see WaIISHost show up in the Currently Monitoring list. AzureTools will attach WinDBG (or whatever you specify in Debugger Location) to a monitored process the next time that process starts up. Note that AzureTools will only attach the next instance of the target process that is started – if the process is currently running then AzureTools will ignore it.

通过调试,我发现我在 Worker Role 的 app.config 文件中缺少 filter 标记的 type 属性。一旦我如下所示添加了它,一切就绪,辅助角色部署成功。

<system.diagnostics>
    <trace>
      <listeners>
        <add type="Microsoft.WindowsAzure.Diagnostics.DiagnosticMonitorTraceListener, Microsoft.WindowsAzure.Diagnostics, Version=2.8.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" name="AzureDiagnostics">
          <filter type="" />
        </add>
      </listeners>
    </trace>
  </system.diagnostics>

请注意,要解决第一个错误,我也可以使用 AzureTools 并通过这种方式进行调试。在大多数情况下,我认为这是明智的做法。碰巧我直到遇到第二个错误才知道该实用程序,并且考虑到我的应用程序尚未生产化,我可以更新我的 DLL 引用。

希望这对其他人有帮助。