I have created a class that communicates with an external program using
a single socket connection. This socket connection is already
thread-safe, so multiple requests to the socket can be made at the same
time.
I am trying to set this up as a global object in an ASP.NET web server
running IIS 5.0, but I'm having a problem with that.
In the Global.asax.cs file, I have added the following reference:
CMyClass _theGlobalObjectOfMyClass;
Then in the Application_Start() routine, I added the following code:
_theGlobalObjectOfMyClass = new CMyClass();
Finally, on one of the pages in question I added the following code:
CMyClass _localReference = (CMyClass)
Application["_theGlobalObjectOfMyClass"];
When I try to load the page in question, I get the following error:
System.NullReferenceException: Object reference not set to an instance
of an object.
I have tried restarting IIS by going on the command line and using the
"iisreset", which tells me that the app is restarted successfully, but
nothing changes when I try to access the page. It's like the global
object is not there?
Anyways, if someone could point out what I'm doing wrong that would be
appreciated. One thing - the object in question is actually being
compiled as a separate DLL and linked into the web project in question
as a reference. Would it make a difference if I was not doing that?
Thanks!