Debugging exceptions in type initializers

I have a static class without a static constructor, but many static members. I throw a TypeInitializationException when the class is first used.

I am breaking CLR exceptions and I have disabled "Just My Code".

The problem is that I get this exception only the first time I use this class; I do not violate the static field initializer. I could, of course, remove the static elements until I find the culprit, but is there an easier way?

Does anyone have any tips on debugging a static field initialization?

+3
source share
2 answers

"", "" ( Ctrl + D, E) , Visual Studio , - . , InnerException, TypeInitializationException, , .

InnerException , .

; , .

+12

  • : "" → → →
  • : Debug → → CLR.

, .

+2

Source: https://habr.com/ru/post/1720743/


All Articles