473,327 Members | 1,976 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,327 software developers and data experts.

public static fields in DLL

Please help anyone: I have made a DLL (for DBCommunication) in which I have
defined some public static variables/fields in a public class. This because I
want these variables to be shared in all methods in the total application.
Both web- and windowsapplications and other DLL's are using this DLL. When
one of the Web-application uses the DLL, my variables are shared across
sessions, but I do not want this to happen - I want the variables to be
unique per session - can't this be done in anyway? The excuse for my English
is that I am a Danish lady in need:-)
Nov 19 '05 #1
3 1752
You should use session variables.

Eliyahu

"Mrs. Conni Drejer" <Mrs. Conni Dr****@discussions.microsoft.com> wrote in
message news:E9**********************************@microsof t.com...
Please help anyone: I have made a DLL (for DBCommunication) in which I have defined some public static variables/fields in a public class. This because I want these variables to be shared in all methods in the total application.
Both web- and windowsapplications and other DLL's are using this DLL. When
one of the Web-application uses the DLL, my variables are shared across
sessions, but I do not want this to happen - I want the variables to be
unique per session - can't this be done in anyway? The excuse for my English is that I am a Danish lady in need:-)

Nov 19 '05 #2
Thank you for your answer, but I cannot use session variables in the DLL or
in my windowsapplications or can I ?

"Eliyahu Goldin" wrote:
You should use session variables.

Eliyahu

"Mrs. Conni Drejer" <Mrs. Conni Dr****@discussions.microsoft.com> wrote in
message news:E9**********************************@microsof t.com...
Please help anyone: I have made a DLL (for DBCommunication) in which I

have
defined some public static variables/fields in a public class. This

because I
want these variables to be shared in all methods in the total application.
Both web- and windowsapplications and other DLL's are using this DLL. When
one of the Web-application uses the DLL, my variables are shared across
sessions, but I do not want this to happen - I want the variables to be
unique per session - can't this be done in anyway? The excuse for my

English
is that I am a Danish lady in need:-)


Nov 19 '05 #3
You are right, you can't use session variables in windows applications. But
you can't use static variables in web applications for the reason you know.
Therefore you have to compromise. The dll has to use something suitable for
both web and windows. For example, a global object responsible for keeping
public data. A web application should use session variables and take care of
instantiating the global object on every request . A windows application can
instantiate the object just once in the beginning.

By the way, there is no problem for a dll running in asp.net application to
access session variables. HttpContext.Current.Session will do the job.

Eliyahu

"Mrs. Conni Drejer" <Mr************@discussions.microsoft.com> wrote in
message news:BD**********************************@microsof t.com...
Thank you for your answer, but I cannot use session variables in the DLL or in my windowsapplications or can I ?

"Eliyahu Goldin" wrote:
You should use session variables.

Eliyahu

"Mrs. Conni Drejer" <Mrs. Conni Dr****@discussions.microsoft.com> wrote in message news:E9**********************************@microsof t.com...
Please help anyone: I have made a DLL (for DBCommunication) in which I

have
defined some public static variables/fields in a public class. This

because I
want these variables to be shared in all methods in the total application. Both web- and windowsapplications and other DLL's are using this DLL. When one of the Web-application uses the DLL, my variables are shared across sessions, but I do not want this to happen - I want the variables to be unique per session - can't this be done in anyway? The excuse for my

English
is that I am a Danish lady in need:-)


Nov 19 '05 #4

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

Similar topics

1
by: Bob Rock | last post by:
Hello, in the last few days I've made my first few attempts at creating mixed C++ managed-unmanaged assemblies and looking aftwerwards with ILDASM at what is visible in those assemblies from a...
1
by: MIchael McDowell | last post by:
Anyidea how this might be done using and XML Web Service and the XMLSerialzation class? A pointer to an online example would be deeply appreciated. Thankyou in advance, Michael McD
0
by: john bailo | last post by:
I am attempting to create a c# program to iterate through the messages in an Outlook/Exchange public folder and extract the headers. My apologies to the VB/VBA groups, but you seem to have more...
3
by: ChristianREMOVE.EitnerTHIS | last post by:
Hi people, I have a class which defines some "public static readonly string" fields. If I say FieldInfo fieldInfos = typeof(DaClass).GetFields(); these fields are reported by reflection,...
3
by: | last post by:
All the fields in webforms are automatically declared as protected. If I change them to public, they are converted back to protected. Why is this happening ? Thanks
8
by: garyusenet | last post by:
The following piece of code appears in an example i'm reading after the class has been named. public string userMessage; However if i move that into my main method, i'm told that the keyword...
1
by: =?Utf-8?B?d3BjbWFtZQ==?= | last post by:
I got the following code public ref class A { value struct PrivateType sealed { Int32 id; }; public: ref struct B abstract sealed { static const PrivateType x = {1}; static const PrivateType...
15
by: archana | last post by:
Hi all, can anyone tell me differene between public static and private static method. how they are allocated and access?. thanks in advance.
4
by: RP | last post by:
I have a class file (Global.cs) containing following variable: Public Int32 TotalRecords=0 I have a Windows Form from where I am assigning a value to this value as below: private void...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.