471,122 Members | 1,025 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,122 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 1662
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by ChristianREMOVE.EitnerTHIS | last post: by
3 posts views Thread by | last post: by
1 post views Thread by =?Utf-8?B?d3BjbWFtZQ==?= | last post: by
4 posts views Thread by RP | last post: by

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.