473,587 Members | 2,547 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to access the Global object

Hi,

I have made a method in Global.asax called from Application_Sta rt event
that loads some cache data from database to Application scope objets.

This is necessary because this is some data from data that don't change
very often.....but it could change.

So I have my method in Global.asax (it can't be Shared because it would
lost Application object scope), and I would like to call it manually to
refresh the cache when necessary.

Other thing I tryed is to move the method to a new class and make it
shared, but "Applicatio n" is not recognized.

How can I access Application object from outside Global.asax and use it
in a Shared sub? or How can I call the "Global" object instance from a
page?

This is the method's code :

Public Sub ReCargarCache()

Application.Loc k()

Application(DC. TipoDeOperacion .ToString) =
StoredProcedure s.GetIdNameTipo DeOperacion.Tab les(0)
Application(DC. Shipper.ToStrin g) =
StoredProcedure s.GetIdNameShip per.Tables(0)
Application(DC. Incoterm.ToStri ng) =
StoredProcedure s.GetIdNameInco term.Tables(0)
Application(DC. MercadoShipper. ToString) =
StoredProcedure s.GetIdNameMerc adoShipper.Tabl es(0)
Application("Co nsignatario") =
StoredProcedure s.GetIdNameProv eedorDeServicio ByServicio(CInt (eTipoDeServici o.eTipoDeServic ioConsignatario )).Tables(0)
Application("No tify") =
Application(DC. Localidad.ToStr ing) =
StoredProcedure s.GetIdNameLoca lidad.Tables(0)
Application(DC. Puerto.ToString ) =
StoredProcedure s.GetIdNamePuer to.Tables(0)
Application("Ag ente") =
StoredProcedure s.GetIdNameProv eedorDeServicio ByServicio(CInt (eTipoDeServici o.eTipoDeServic ioAgenteMaritim o)).Tables(0)
Application(DC. Motonave.ToStri ng) =
StoredProcedure s.GetIdNameMoto nave.Tables(0)
Application(DC. Terminal.ToStri ng) =
StoredProcedure s.GetIdNameTerm inal.Tables(0)

Application.UnL ock()

End Sub

Regards
Fabio

Nov 23 '05 #1
1 1398
On 23 Nov 2005 11:24:08 -0800, "Fabio Cavassini"
<ca********@gma il.com> wrote:
How can I access Application object from outside Global.asax and use it
in a Shared sub? or How can I call the "Global" object instance from a
page?


You could always put this code in a Shared Sub outside of global.asax
and use a different synchronization technique, for instance
Monitor.Enter, Monitor.Exit, or a ReaderWriterLoc k object.
http://msdn.microsoft.com/library/de...classtopic.asp

--
Scott
http://www.OdeToCode.com/blogs/scott/
Nov 24 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
23864
by: Nicola | last post by:
Hi Everyone, I am new to programming and would like to know how to open an access Report from within vb 6. I am trying to write a program to organise cross stitch threads. I have found out how to use a database table but all I want to do now is to click a command button to display this access report. Any suggestions please ?????
2
1616
by: trebor | last post by:
I added a couple of class files to a VS web project, and I can't access the application object from inside them. The system treats them like undeclared variables. Is there an Imports I have to use? The value that I need global to the entire project is the oleDB connection string ("Provider=.... Data Source=C:\..."). What I've done in the...
10
3022
by: Ronnie | last post by:
I've created a simple web application using VS2005 Beta 2. Basically, I've added a Web Form and a Global.asax file. In my Global.asax, I create a method like: public static void TestGlobal() { throw new Exception("Foobar"); }
4
2003
by: lars.uffmann | last post by:
Hey everyone! I am (still) working on a project that I took over from former students, so don't blame me for the criminal approach on coding *g* The problem I have is fairly easy and while I have solutions, none of them seems really "clean" to me and I was wondering if someone here maybe had a better idea: class geometry { ... }
1
4467
by: romeo_a_casiple | last post by:
I'm looking to create an static object that has application scope and be able to access that static object from my web service. I understand there are two ways to do this : 1) use the object tag in the global.asax, such as: <object id="objObject" runat="server" class="TestApplication.MyClass" scope="Application" />
1
1410
by: andy_w_irvine | last post by:
Hi, Apologies if this has been asked elsewhere, I did search but expect I didn't hit on the required terminology. I want to be able to use a string variable called objectName (original!) to get a reference to an instance of my object courseObject - created using the following code. function...
5
2673
by: Lyle Fairfield | last post by:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dndotnet/html/callnetfrcom.asp The Joy of Interoperability Sometimes a revolution in programming forces you to abandon all that's come before. To take an extreme example, suppose you have been writing Visual Basic applications for years now. If you're like many developers,...
1
3104
by: gm | last post by:
Hi; I have written a database that tracks all the installation we have ever done. I have a small heating company. I have recently started keeping a directory of digital photographs of the completed job. I can create a hyperlink button that will link to a photgraph, but I cannot link to a specific photo of that specific job. Each job has its'...
3
18073
by: Dylan Parry | last post by:
Hi folks, I've just got a new machine at work, so I've spent all day copying across all of my work from my old machine. Now I've come across a problem that I've never seen before. I now get the following error when I attempt to run one of my sites: "Access to the registry key 'Global' is denied"
36
2014
by: Peter Olcott | last post by:
So far the only way that I found to do this was by making a single global instance of the container class and providing access to the contained class, through this single global instance. Are there any other no-overhead ways that a contained class can access its container? The obvious choice of passing (a pointer or a reference to the...
0
7920
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7849
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8215
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8347
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7973
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
8220
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6626
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
2358
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1189
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.