By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,206 Members | 1,020 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,206 IT Pros & Developers. It's quick & easy.

NullReferenceException with shared members

P: n/a
Hello fellow coders,

I 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.


For my application i have chosen to make my own "Environment"
This environment contains Variables and Methods that are Shared.

For Example


Public Shared Property MyObject as MyObject
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


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

Oct 6 '06 #1
Share this Question
Share on Google+
2 Replies

P: n/a
Okay so there is no need to reply as i have just solved my problem...

theEnvironment.Object was not instantiated..

the member declaration was altered from
Dim mObject as MyObject
Dim mObject as NEW MyObject

Rofl :P

Oct 6 '06 #2

P: n/a
the member declaration was altered from
Dim mObject as MyObject
Dim mObject as NEW MyObject

Rofl :P

The number of times I've done
Oct 6 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.