Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8752805
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T13:18:22+00:00 2026-06-13T13:18:22+00:00

I am getting a run-time error The type initializer for ‘SensionVB.CommonCall’ threw an exception.

  • 0

I am getting a run-time error “The type initializer for ‘SensionVB.CommonCall’ threw an exception.” when trying instantiate the object call:

Dim general As New SensionVB.CommonCall

When stepping through the code once it hits the above line in code and fails, it does .

The suggestions from Microsoft are to check for null, or add new neither is true in this case

SensionVB = Project
CommonCall = Public Class with various functions

Public Class CommonCall
Protected WithEvents litOne As System.Web.UI.WebControls.Literal
Public Shared sConnection As String = ConfigurationManager.ConnectionStrings("SerialStamperConnectionString").ConnectionString
Public Shared oConnection As New MySqlClient.MySqlConnection(sConnection)
Public Shared sMaxSerialNumber As String = "S000001"
Public Shared bLoggedin As Boolean = False
Public Shared iPageWidth As Integer = 1024

Public Shared isValidPassword As Boolean = False
Public Shared strCompanyID As String = ""
Public Shared strSecurityID As String = ""

Dim Response As New HttpResponse(HttpWriter.Null)
Const TimeOutInMinutes As Integer = 60
Const SiteTitle As String = "SensiOn"
Public Const PageWidth As Integer = 1250
Public SSOenabled As Boolean
Const SuperUserEmails As String = "super@domain.com"
Public Sub Initialize()
    oConnection.Open()
End Sub
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T13:18:23+00:00Added an answer on June 13, 2026 at 1:18 pm

    I see three lines that may possibly be the culprit:


    Public Shared sConnection As String = ConfigurationManager.ConnectionStrings("SerialStamperConnectionString").ConnectionString
    

    There are several potential issues here. One, your connection string name (“SerialStamperConnectionString”) is incorrect. If this name does not match a key in the web.config, then it will return Nothing, causing a NullReferenceException when you attempt to get the value of the ConnectionString property.


    Public Shared oConnection As New MySqlClient.MySqlConnection(sConnection)
    

    It’s possible that your connection string above is not configured properly in the web.config, thus returning Nothing as the ConnectionString. If sConnection has been set to Nothing, it’s possible that a NullReferenceException could be thrown my the MysqlConnection constructor.


    Dim Response As New HttpResponse(HttpWriter.Null)
    

    If HttpWriter.Null is Nothing then this could also be the source of your problem (for the same reason noted above).


    If none of these suggestions seem to be causing the problem, then I would suggest posting more information about your issue (including the stack trace). Offering a million reputation points will not give us any additional information about your code.


    ADDENDUM
    According to the VB documentation on Shared constructors (and, by extension, members):

    Exactly when shared constructors are run is mostly implementation dependent, though several guarantees are provided if a shared constructor is explicitly defined:

    • Shared constructors are run before any instance of a class type is created.
    • Shared constructors are run before any instance members of a structure type are accessed, or before any constructor of a structure type is explicitly called. Calling the implicit parameterless constructor created for structures will not cause the shared constructor to run.
    • Shared constructors are run before any of the type’s shared members are referenced.
    • Shared constructors are run before any types that derive from the type are loaded.
    • A shared constructor will not be run more than once during a single execution of a program.

    9.3.2 Shared Constructors

    You may find it useful to create a Shared constructor in which to initialize your shared fields:

    Public Shared sConnection As String
    Public Shared oConnection As MySqlClient.MySqlConnection
    
    Shared Sub New()
        Dim l_connectionString = ConfigurationManager.ConnectionStrings("SerialStamperConnectionString")
        If l_connectionString IsNot Nothing Then
            sConnection = l_connectionString.ConnectionString
            oConnection = New MySqlClient.MySqlConnection(sConnection)
        Else
            ' What to do here?
        End If
    End Sub
    

    This will not solve your problem, most likely, but it may make it easier to find and to handle (null string, etc.)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I keep getting a Run Time error that says I am having an Exception
Trying to use CIColorMap filter, but getting run-time error [NSImage _feImage]: unrecognized selector sent
Am getting Run-time error 13 . Type Mismatch. But i cant figure out why.
Trying to get radiobuttons binding working but getting a run time error with the
I am getting this run time error when using IID_IWebBrowser2 interface of CLSID_InternetExplorer. Run-Time
Hi I am getting a Run time Error saying that the stack around szDeviceType
I am getting an XP0006 error when trying to run an XQuery transformation (OSB's
In VSTO (Visual studio to Office) project I am getting following exception: Error: type
In a Silverlight 4 app I'm trying to instantiate an object whose type isn't
I'm getting this error when I try run DB:Rake : ** Invoke db:migrate (first_time)

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.