473,396 Members | 1,785 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

asp.net + static/shared classes

jg
Im experience some problems with static/shared classes in asp.net, Im saving
some object as static so that they are allways available but the code in the
static/shared constructors doesnt seem to execute??
Nov 18 '05 #1
3 1033
"jg" <ph*****@obmocje51.net> wrote in
news:ey**************@tk2msftngp13.phx.gbl:
Im experience some problems with static/shared classes in asp.net, Im
saving some object as static so that they are allways available but
the code in the static/shared constructors doesnt seem to execute??

Are just calling the functions directly... i.e: SharedClass.SharedFunction?

If this is the case, the constructor won't be executed since the object is
not really created. If you wish to execute the constructor, you'll need to
explicitly create the object (i.e. dim object = new object()).

Nov 18 '05 #2
jg
hmmm, Im using C#, I dont think you can initialize a static object with new?
"Anon-E-Moose" <an**********@yahoo.com> wrote in message
news:Xn********************************@140.99.99. 130...
"jg" <ph*****@obmocje51.net> wrote in
news:ey**************@tk2msftngp13.phx.gbl:
Im experience some problems with static/shared classes in asp.net, Im
saving some object as static so that they are allways available but
the code in the static/shared constructors doesnt seem to execute??

Are just calling the functions directly... i.e:

SharedClass.SharedFunction?
If this is the case, the constructor won't be executed since the object is
not really created. If you wish to execute the constructor, you'll need to
explicitly create the object (i.e. dim object = new object()).

Nov 18 '05 #3
You should show some code that you think is not executing, and give us the
minimum relevant code to look at.

Also, try setting a breakpoint in the static constructor before the first
reference to a static object is made in your app (so do this right after
asp.net restarts, but before the first call to your object happens).

"jg" <ph*****@obmocje51.net> wrote in message
news:ey****************@tk2msftngp13.phx.gbl...
Im experience some problems with static/shared classes in asp.net, Im saving some object as static so that they are allways available but the code in the static/shared constructors doesnt seem to execute??

Nov 18 '05 #4

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

Similar topics

16
by: Bruno Rodrigues | last post by:
Hi In a class with simple methods like: Products.Insert(string name, string desc) Products.Update(int id, string name, string desc) Products.Delete(int id) What is better? Static or common...
4
by: MPF | last post by:
When designing a n-tier architecture, what is the preferred method/function accessibility? <Specifically for asp.net apps> A private constructor and shared/static methods & functions? A public...
11
by: dee | last post by:
OleDbCommand class like many .NET classes has the following description in its help file: "Thread Safety Any public static (Shared in Visual Basic) members of this type are safe for...
2
by: Random | last post by:
Here's a design question I'm curious to know if anyone here has wrestled with before... I'm writing my data access methods in classes in the App_Code directory. I know that I can easily...
5
by: Andy B | last post by:
I have a class that I want to make static but it uses some objects that are instance objects. I keep getting a compiler error saying something about using instance objects in a static class or...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
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...
0
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,...
0
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...
0
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...

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.