The type initializer for 'MyClass' threw an exception.

I

ibiza

Hi all,

I have this class:

Public Class KanaConverter
Private Shared kana As ArrayList
Private Shared romanji As ArrayList

Shared Sub New()
kana = New ArrayList
romanji = New ArrayList
Dim r As Data.SqlClient.SqlDataReader = japDB.getHiragana()
While r.Read()
kana.Add(r("hiragana"))
romanji.Add(r("hiragana_roman"))
End While
End Sub

Shared Function KanaToRomanji(ByVal sIn As String) As String
...
End Function
End Class

and when I do this in my page load:
Dim s As String = KanaConverter.KanaToRomanji("ãŒãã›ã„")
it doesn't even get to the shared constructor and throws that exception
before :
"The type initializer for 'KanaConverter' threw an exception."

What is it supposed to mean?
 
J

Jon Skeet [C# MVP]

ibiza said:
I have this class:

and when I do this in my page load:
Dim s As String = KanaConverter.KanaToRomanji("????")
it doesn't even get to the shared constructor and throws that exception
before :
"The type initializer for 'KanaConverter' threw an exception."

What is it supposed to mean?

The "shared constructor" *is* the type initializer. If you catch the
TypeInitializationException, you can look at the inner exception to
find out what was wrong.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,904
Latest member
HealthyVisionsCBDPrice

Latest Threads

Top