Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Webjob throws a TypeInitializationException during startup #3041

Open
shadowano opened this issue Nov 8, 2023 · 0 comments
Open

Webjob throws a TypeInitializationException during startup #3041

shadowano opened this issue Nov 8, 2023 · 0 comments

Comments

@shadowano
Copy link

shadowano commented Nov 8, 2023

I have webjobs written in .NET Framework 4.7.2 that have lived for years, and have this week upgraded them to use latest Azure.Storage.* nuget packages instead of WindowsAzure.Storage. I have also removed a lot of unused deprecated Microsoft.AspNetCore.* packages in my webjobs.

Even before I did the upgrades above, I get the following error in console during startup of my webjobs:

Unexpcted Exception During Runtime Startup:
System.TypeInitializationException: The type initializer for '<Module>' threw an exception. ---> <CrtImplementationDetails>.ModuleLoadException: The C++ module failed to load while attempting to initialize the default appdomain.
 ---> System.Runtime.InteropServices.COMException: Invalid operation. (Exception from HRESULT: 0x80131022)
   at System.Runtime.InteropServices.Marshal.ThrowExceptionForHRInternal(Int32 errorCode, IntPtr errorInfo)
   at <CrtImplementationDetails>.GetDefaultDomain()
   at <CrtImplementationDetails>.DoCallBackInDefaultDomain(IntPtr function, Void* cookie)
   at <CrtImplementationDetails>.LanguageSupport.InitializeDefaultAppDomain(LanguageSupport* )
   at <CrtImplementationDetails>.LanguageSupport._Initialize(LanguageSupport* )
   at <CrtImplementationDetails>.LanguageSupport.Initialize(LanguageSupport* )
   --- End of inner exception stack trace ---
   at <CrtImplementationDetails>.LanguageSupport.Initialize(LanguageSupport* )
   at .cctor()
   --- End of inner exception stack trace ---
   at Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment.InitializeEnvironment()
   at Microsoft.WindowsAzure.ServiceRuntime.RoleEnvironment..cctor()

The webjob runs and work just fine even if this exception is thrown during startup. I had this error even before I started upgrading and fixing deprecated nuget packages.

What causes this exception to be thrown, and how can I fix it?

Related information

Provide any related information
Microsoft.Azure.WebJobs 3.0.39
Microsoft.Azure.WebJobs.Core 3.0.39
Microsoft.Azure.WebJobs.Extensions 5.0.0
Microsoft.Azure.WebJobs.Extensions.Storage.Queues 5.2.0
Microsoft.Azure.WebJobs.Host.Storage 5.0.0

I do not have any Microsoft.WindowsAzure* nuget packages installed in my projects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant