468,321 Members | 1,811 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,321 developers. It's quick & easy.

The type initializer for 'MyClass' threw an exception.

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?

Feb 25 '06 #1
1 7141
ibiza <la******@gmail.com> wrote:
I have this class:
<snip>
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.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Feb 25 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by =?Utf-8?B?YmlqYXk=?= | last post: by
4 posts views Thread by =?Utf-8?B?YmlqYXk=?= | last post: by
2 posts views Thread by tshad | last post: by
1 post views Thread by howard w | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.