473,799 Members | 3,098 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Access global static object from web service ?

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="TestAppl ication.MyClass "
scope="Applicat ion" />

-- or --

2) Write a codebehind class and inherit from that in the global.asax
My question is, how can I access the static object from within my web
service ?

With method 1), if I access "objObject" from the web service code it
will not compile. I understand this might work if I was coding an
ASP.NET page, but this is a web service.

Any clues?

Jan 17 '06 #1
1 4472
you can use singletone pattern in order to get the result you want

public class BigStaticObject
{
static object sync = new object();
static BigStaticObject instance = new BigStaticObject ();
private BigStaticObject ()
{}

public static BigStaticObject Instance
{
get
{
lock(sync)
{
if ( instance == null )
instance = new BigStaticObject ();
return instance;
}
}
}
}

--
Vadym Stetsyak aka Vadmyst
http://vadmyst.blogspot.com

<ro************ *@hotmail.com> wrote in message
news:11******** *************@g 47g2000cwa.goog legroups.com...
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="TestAppl ication.MyClass "
scope="Applicat ion" />

-- or --

2) Write a codebehind class and inherit from that in the global.asax
My question is, how can I access the static object from within my web
service ?

With method 1), if I access "objObject" from the web service code it
will not compile. I understand this might work if I was coding an
ASP.NET page, but this is a web service.

Any clues?

Jan 18 '06 #2

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

Similar topics

9
1389
by: John Bailo | last post by:
As far as I can tell, there is no way in a Web service, per se, to have a truly shared object or resource such as a file...one that I can manage multiple updates on with a mutex for both reading and writing. Therefore, I think I should use a Remoted service that manages calls to the file, with a mutex. I would then call the Remoted service from the web service calls. Thoughts?
9
4162
by: Clint | last post by:
Hey all - Excuse the cross-post ... I'm not sure what the appropriate newsgroup would be for this question. I have a question that I'm not quite sure how to ask. For all I know, I have the verbaige completely wrong, but here goes nothing ... I'm currently using the MS Data Access Block for a desktop application I'm writing. Recently, I had to add a call to a web service, which in
8
2891
by: Marty | last post by:
Hi, I'm new to C#, I used to code in VB.NET. Where is the best place to declare all my constants and global objects in my C# project to have them accessible globally? I have an event logger class that I want its instance to be accessible from any other classe in the project. There is also a bunch of constants that I want to be public for the
19
2071
by: Shiv Kumar | last post by:
I see that the Application_OnStart event is fired only once for a certain application. I'm interested in creating a "global" object (an object that will be available to all requests for the application). I thought I could use this event to create an instance of my object. I find that the event does get fired and an instance is created. However, when I reference this object from a page it is null. What gives? What is the recommended way...
29
15554
by: Patrick | last post by:
I have the following code, which regardless which works fine and logs to the EventViewer regardless of whether <processModel/> section of machine.config is set to username="SYSTEM" or "machine" ---Start of test.aspx---- <%@ Page language="C#" AutoEventWireup="false" %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" > <HTML> <HEAD>
3
1792
by: rwoo_98 | last post by:
Does anyone know the difference between defining a static variable inside Global vs using an Application variable? For example Using a static int variable. public class Global : System.Web.HttpApplication { public static int MaxValue
2
2338
by: arun1985 | last post by:
In the project i am using i am having the following code and when i upload it to the server.Its givig me the following error in the global.cs file. Server Error in '/' Application. -------------------------------------------------------------------------------- Object reference not set to an instance of an object. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack...
10
3581
by: ma | last post by:
Hello, I want to create a global class. To do this I did the followings: 1- Create a class name test. It has a public variable named mystring. public class test { public string mystring = "hello world";
3
1792
by: Sune | last post by:
Hi all, I'm not a C# programmer so please be gentle: Prereq: --------------- - The lookup service (see below) implemented by a C module cannot be re-written in C# ;-) - The lookup service is to be loaded into the process of the C# application, i.e. I want to avoid expensive IPC
0
9687
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 usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9541
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10251
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 captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
10027
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7564
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5463
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5585
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4139
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
3
2938
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 effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.