Azure worker role throwing System.IO.FileNotFoundException

1

I redeployed an operational Azure worker role with a few changes that involve referencing a new class library project I have set up and have begun to see the worker role endlessly reboot/recycle.

The Event Viewer Application logs provide very little help as the error I receive is very generic.

Source: .NET Runtime

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[])

Source: Application Error

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:

I've searched for this but haven't come across anyone receiving an error message as generic as this.

My own logging doesn't provide much insight either. All I know is that the WorkerRole doesn't hit the OnStart method.

Are there any other logs that could help narrow down the issue?

Thanks in advance.

c#
.net
azure
reflection
azure-worker-roles
asked on Stack Overflow Feb 15, 2017 by RizJa

1 Answer

1

Figured it out... but not in the most graceful of ways.

I went ahead and updated all DLLs from Nuget for the worker role and class library projects. Something in there fixed that problem (I know, bad right?) but then I was faced with another:

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[])

To solve this, I eventually stumbled across here, which led me to this. I downloaded AzureTools on my Worker Role VM and attached a debugger to the recycling WaWorkerHost process. The following is a relevant excerpt from the aforementioned 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.

Debugging through this, I found out that I was missing the type attribute for my filter tag in the Worker Role's app.config file. Once I added that in as shown below, everything fell into place and the worker role deployed successfully.

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

Note that to resolve the first error, I could have also used AzureTools and debugged through that way. In most cases, I would consider that the advisable approach. It just so happens that I didn't find out about the utility until I was confronted with the second error and given that my application has not yet been productionized, I could afford to update my DLL references.

Hope this helps someone else.

answered on Stack Overflow Feb 16, 2017 by RizJa

User contributions licensed under CC BY-SA 3.0