-
Feb 9th, 2010, 11:14 PM
#1
Thread Starter
Member
How to avoid "The type initializer for... threw an exception"
I just created this program 2 weeks ago, and stop doing for two weeks... before, it perfectly run and has no errors on all of my instance variable that i declared, though in is not finish...
When I'm about to continue doing my project, this error suddenly appear,... Even my 'StrSQL' variable which I declare in my Module as follow:
Code:
Public strSQL as String
and upon calling the variable it also has that error... same with this declarion inside my modGlobal module,
Code:
Public RoomWindow As New frmRoomWindow
Public AccountReceivable As New frmAccRecLookUp
Public GuestLookup As New frmGuestLookup
Public ReservationLookup As New frmReservLookup
Public AlterData As New frmAlterData
Public Checkin As New frmCheckIn
Public ManageAccount As New frmManageAccounts
Public ucButton As New ucAA_Button
Public usermain As New ucUserInformation
Public room As New ucRoom
Public paymenttype As New ucPaymentType
Public idtype As New ucIDType
Public customer As New ucCustomer
Public company As New ucCompany
Public charges As New ucChargeType
Public accountrecord As New ucAccountRecord
All of them suddenly has that error,...
What would be the problem with this?... I'm stock with this problem...
Does my Visual Studio 2008 has the problem?
-
Feb 11th, 2010, 10:35 AM
#2
Re: How to avoid "The type initializer for... threw an exception"
You need to supply more details.
What is the exact message in regards to the error? The more details the better readers can assist you.
-
Feb 11th, 2010, 10:51 AM
#3
Thread Starter
Member
Re: How to avoid "The type initializer for... threw an exception"
That's the only errors it show, along with name of the instance that I first declared in my Module,...
Code:
The type initializer for 'ucButton' threw an exception
I tried to recreate the same form in my project that has this error with exact declaration of the variable and instances, and it runs fine...
-
Feb 11th, 2010, 11:03 AM
#4
Re: How to avoid "The type initializer for... threw an exception"
Originally Posted by jasluv
That's the only errors it show, along with name of the instance that I first declared in my Module,...
Code:
The type initializer for 'ucButton' threw an exception
I tried to recreate the same form in my project that has this error with exact declaration of the variable and instances, and it runs fine...
What is ucButton? Is it a standard button or a custom button?
-
Feb 11th, 2010, 11:09 AM
#5
Thread Starter
Member
Re: How to avoid "The type initializer for... threw an exception"
My mistakes... I replied wrong error message...
this the right error message anyway..
Code:
The type initializer for 'HotelMngtSystem_SAD2_.modGlobal' threw an exception.
The content of modGlobal procedure all the instances of my User Control and Public Variables, a Posted in my first post... all of it's content produces that kind of error...
-
Feb 11th, 2010, 11:18 AM
#6
Re: How to avoid "The type initializer for... threw an exception"
My first thought is if everything worked two weeks ago and now to your knowledge nothing has changed I would begin by looking for a single line of code that does not seem right.
For instance, when leaving the project last time (I have seen this happen) a key was entered upon exit on the current line.
For instance, the current line was
Dim Name as String
Somehow it ended up as
Dim Namse as String
Which if global and used a lot could toss issues into other code and produce what I call a false positive exception where the actual reported exception is incorrect and another exception is there.
Either way this is when using source control software is a huge plus as you can go back to a prior version of your project to before the problem.
-
Feb 11th, 2010, 11:29 AM
#7
Thread Starter
Member
Re: How to avoid "The type initializer for... threw an exception"
I already reviewed all of that... It really confused me why this happened, while in my other project that has the same declaration with this works perfectly and has nor errors..
-
Feb 11th, 2010, 12:20 PM
#8
Re: How to avoid "The type initializer for... threw an exception"
Originally Posted by jasluv
I already reviewed all of that... It really confused me why this happened, while in my other project that has the same declaration with this works perfectly and has nor errors..
If you do not have a backup make one now.
Make sure you have the proper framework selected, can not hurt to check
Next start peeling away layers in an attempt to see if you can figure out what is the item causing the problem.
At this point with this type of project it's all comes down to detective work.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|