Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Static constructor in VB.NET

I am rewriting a C# class in VB.NET. The C# class has a static constructor in it:

static Class()
{
    ...
}

which, through the call stack, I found is called by the main window's InitializeComponent() method. Everywhere I've looked has told me that the corresponding static constructor in VB.NET is just:

Shared Sub New()
    ...
End Sub

But this method is never invoked. Am I creating my VB.NET static constructor right? Is it likely something else that has nothing to do with my static constructor?

like image 203
Seth Moore Avatar asked Feb 09 '10 15:02

Seth Moore


1 Answers

The static constructor 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 members of that class is accessed/referenced.
like image 153
KV Prajapati Avatar answered Oct 23 '22 15:10

KV Prajapati