public static fields in DLL

G

Guest

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:)
 
G

Guest

Thank you for your answer, but I cannot use session variables in the DLL or
in my windowsapplications or can I ?
 
E

Eliyahu Goldin

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,231
Members
46,820
Latest member
GilbertoA5

Latest Threads

Top