Reputation: 455
I've been working on a program for the past month, pretty simple, but it have to load multiple forms, especially since there is a launcher. Everything worked well till this morning, where I accenttally pressed "Yes" when a Pop-up asked me something I didn't have time to read.
Since then, I've been getting
TypeInitializationException
and
NullReferenceException
When opening Form2
from Form1
Form2.Variable = Form1.Textbox.Text
Form2.Show()
Upvotes: 1
Views: 35
Reputation: 210
The TypeInitializationException (the exception that you are seeing) is thrown whenever a static constructor throws an exception, or whenever you attempt to access a class where the static constructor threw an exception.
With the NullReferenceException you are probably trying to use something that is null (or Nothing in VB.NET). This means you either set it to null, or you never set it to anything at all.
Like anything else, null gets passed around. If it is null in method "A", it could be that method "B" passed a null to method "A". - taken from this brilliant answer on this post
If you post more code or that I could potentially see whats wrong but good placce to start is setting any vairbales to nothing
and also checking any dll you insert are still there etc.
string foo = null;
foo.ToUpper()
would cause a nullexception so maybe it's occuring when the textbox is empty?
Upvotes: 2