You are not the only one who have seen this error which to many, means no sense at all sometimes. However, you can always get some clue from those who are more experienced. This articlde from codebetter lists 3 of the common causes of the error message.
Just for the sake of a summary, here are the 3 main causes:
1. In VB.Net, you are trying to access a string that has not been initialized. In C#, this isn’t possible. You can’t even compile code like the following in C#
2. You never created a new instance of an object. Again, this is code that C# will not compile, but VB.Net will, and throw a runtime error. Same as a string, any reference type must be initialized. Strings and some other CTS types have a misconception of being value types, like Integers, and they are not.
3. You created the object, but killed it too soon (ex. setting it to Nothing too soon) and as a result there is no existing instance for the object anymore.
Hope you find this useful and can learn something from it, especially to fix that annoying error message 🙂
Leave a Reply