Au-Yeung Kham Sau
Au-Yeung Kham Sau

Reputation: 123

vb.net "The type initializer threw an exception" issue

I encountered this exception when I trying to load a certain page. It doesn't show me which line of code has problem, which makes me kind of dizzy now..

What is a type initializer? What is it used for? and how can I troubleshoot this problem? Any suggestion?

Upvotes: 0

Views: 2163

Answers (1)

KV Prajapati
KV Prajapati

Reputation: 94643

Type initializer or static constuctor is block of code that is triggered by the first of the following events to occur within an application domain.

  1. An instance of that class is created
  2. Any of the static member of that class is accessed/referenced.

For more info read articles by Jon skeet.

  1. C# and beforefieldinit (C# in depth chapter)
  2. Type initialization changes in .NET 4.0

Upvotes: 0

Related Questions