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

Hooking into Application objects

P: n/a
I am trying to write a static utility class that allows me to modify
Application variables in my web application.

My problem is that I cannot figure out what to import or inherit to
allow me to see application objects or even the server object.

Here is my code:

Public Shared RefreshCachedXMLDatasets()

Dim dsLinks As New DataSet()
'-- Cached XML Menu
dsLinks = New DataSet()
dsLinks.ReadXml(Server.MapPath(Utilities.GetConfig Value("XMLMenuFilename",
"")))
Application("CACHED_XML_MENU") = dsLinks

'-- Cached Portfolio
dsLinks = New DataSet()
dsLinks.ReadXml(Server.MapPath(Utilities.GetConfig Value("XMLPortfolioFilename",
"")))
Application("CACHED_XML_PORTFOLIO") = dsLinks
End Sub

The application object or server object do not exsist.
Any Suggestions?
Nov 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Hi Brian,

I would suggest implementing this class as an amended singleton. It would
have an Initialize method creating the sole instance which would accept the
Application object as the argument. This method would be called upon
Application_OnStart. Then, it would have the standard singleton Instance
property to access the sole instance. This instance will have been
pre-initialized with a reference to the application object by the moment you
will be accessing it for the first time.

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

"Brian Bender" <br***********@hotmail.com> wrote in message
news:b7**************************@posting.google.c om...
I am trying to write a static utility class that allows me to modify
Application variables in my web application.

My problem is that I cannot figure out what to import or inherit to
allow me to see application objects or even the server object.

Here is my code:

Public Shared RefreshCachedXMLDatasets()

Dim dsLinks As New DataSet()
'-- Cached XML Menu
dsLinks = New DataSet()
dsLinks.ReadXml(Server.MapPath(Utilities.GetConfig Value("XMLMenuFilename", "")))
Application("CACHED_XML_MENU") = dsLinks

'-- Cached Portfolio
dsLinks = New DataSet()
dsLinks.ReadXml(Server.MapPath(Utilities.GetConfig Value("XMLPortfolioFilenam
e", "")))
Application("CACHED_XML_PORTFOLIO") = dsLinks
End Sub

The application object or server object do not exsist.
Any Suggestions?


Nov 20 '05 #2

P: n/a
Dmitriy,

I uderstand what you are saying. i am familiar with singleton. However
isn't there a built in way to do this. All webforms are classes and
they see these objects. How do they do it? It has got to be some type
of import or inheritance.
Nov 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.