|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
NullReferenceException with shared membersI have run into an issue that is otherwise painfull for my brain to think about at this point so i turn to you guys for input. Scenario. For my application i have chosen to make my own "Environment" This environment contains Variables and Methods that are Shared. For Example 'Properties Public Shared Property MyObject as MyObject Get~~~~ Set~~~~ End Property Now i have basicly implemented 2 of these environment classes. one contains native .NET elements (SqlConnection to be specific) and the other one can be seen in the Example above. The one that is causing me problems is the environment as seen above and it contains an Object that i have defined. The working one i have implemented like this.... Dim MyConnection as SqlConnection MyConnection = Stuff theEnvironment.DbConnection = MyConnection The broken one i have implemented like this.... Dim MyObj as MyObject '<-- i created this objects class MyObj = Stuff theEnvironment.MyObject = MyObj The actual meaning of what im doing is a Login Screen that Takes the Users credentials and puts it into the environment so that other parts of the application can access it. The Environment contains DbConnection UserObject The UserObject contains a constructor with NON shared properties one of which is another Object. ----------------------------------------------------------------------------- I hope i have given enough information to outline the problem Okay so there is no need to reply as i have just solved my problem...
Cause theEnvironment.Object was not instantiated.. Solution the member declaration was altered from Dim mObject as MyObject to Dim mObject as NEW MyObject Rofl :P > the member declaration was altered from The number of times I've done > Dim mObject as MyObject > to > Dim mObject as NEW MyObject > > Rofl :P that.............................................. |
|||||||||||||||||||||||