Skip to content

TypeInitializationException: The type initializer for '<Module>' threw an exception #325

@KristianRT

Description

@KristianRT

Hi

We have an desktop application that we are obfuscate using ConfuserEx 1.5.0. When running our application it works fine most of the time. However we experience that an TypeInitializationException is thrown at different places in our code. The stack trace looks random and we see no pattern in when the exception is thrown. Sometimes the application have just started, other times the application runs for a few hours before the exception happens.
We have made an automated integration test that simulated user input and loops over the same actions again and again. We have tested our software both with and without obfuscation. The results are consistent and reproducible. When the software is not obfuscated it runs stable until me manually stop it (after a few days), but when we run the obfuscated version we get the TypeInitializationException within a few hours. Usually after between 1 to 4 hours.

The stack trace is always looks like this:

System.TypeInitializationException: The type initializer for '' threw an exception. ---> System.ComponentModel.Win32Exception: Unknown error (0xc0000008)
at .‫‭​‭‍‌‌‭‭‫‪‎‎‌‌​‌‌‌‬‬‎‍‪‏‍‮.‏‌​‮‫‪​‌‍‮‎‌‮​‫‭‫‌‌​‬‏‌‌‍‌‫‬‮(IntPtr )
at ‫‍‫‏‍‏‏‬​‬‮‪‭‫‫​‫‪‏‪‫‏‭‍‍‪‫‍‮‮()
at .cctor()
--- End of inner exception stack trace ---
[Random part of the stack trace. This part seems random and are either coming from our own code or inside some System.X assemblies, such as System.Windows.Forms or System.Threading]
Win32Exception details:
Message=Unknown error (0xc0000008)
ErrorCode=-2147467259
NativeErrorCode=-1073741816
StackTrace= at .‭‫‍‬‭‮‎‎‏‫‌‍‪‌‎‬‮‏‭‪‫​‏‬‮‮.‌‏‏‮‎‫‍‍​‍‫‎‌‎‫​‏‫‮‍‪‮‮‭​‬‪‮(IntPtr )
at ‭‍‎‍‭‌‫‪‏‪‮‎‫‮‫‍‮‍​‫​‎​‬​‌‮​‎‮()
at .cctor()
Source=VM
BaseException=System.ComponentModel.Win32Exception (0x80004005): Unknown error (0xc0000008)
at .‭‫‍‬‭‮‎‎‏‫‌‍‪‌‎‬‮‏‭‪‫​‏‬‮‮.‌‏‏‮‎‫‍‍​‍‫‎‌‎‫​‏‫‮‍‪‮‮‭​‬‪‮(IntPtr )
at ‭‍‎‍‭‌‫‪‏‪‮‎‫‮‫‍‮‍​‫​‎​‬​‌‮​‎‮()
at .cctor()

The line "Source=VM" refer to one of our dll's called "VM.dll". It is also random which of our dll's that source points to.

  • ConfuserEx Version: 1.5.0 (downloaded from here: https://github.com/mkaring/ConfuserEx/releases)
  • Target Framework: .Net 4.6.1
  • Operating System: Windows 10 64bit
  • ConfuserEx project file (*.crproj): ConfuserX-template.txt
  • We've got the TypeInitializationException on several different PCs, but are running the testing on a Windows 10 64bit, having .Net Framework v4.7.1.

This error might be related to #301. At least they both experience TypeInitializationException.

We would like to continue to use ConfuserEx to obfuscate our code and would appreciate any guidance that the maintainers may be able to provide to understand why this issue occurred and how we can prevent it in the future. Please let me know if there is any additional information that I can provide and I will follow up accordingly.
Thank you!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions