|
-
Oct 15th, 2002, 09:03 AM
#1
Arggh. I actually need help(static/shared variables)
Hey guys, I need a hand.
I have a dll that has a static hashtable(object collection) variable that is public. One executable loads it and instantiates the dll and sticks some objects into that hashtable. Now a second exe is supposed to instantiate the dll and with the variable being statis/shared, the second exe should get the value of the hashtable variable as it has been populated by the first exe. But unfortuantly it does not. The varaible is blank. Am I missing anything that I need to do other than make the shared?
-
Oct 15th, 2002, 10:12 AM
#2
Frenzied Member
Yes Cander you are indeed missing something .
If a variable is declared static or shared in a class, that variable will be invisible if that class is instanitated.
eg
Code:
public class MyClass
{
public static int myInt;
public int myNextInt;
public MyClass()
{}
}
Code:
MyClass mc = new MyClass();
mc.myNextInt = 1; //This is the only member that will show up
//to get myInt you would have to do this
MyClass.myInt = 1;
If you want to get values into a static or shared variable, do not instantiate the class with those static or shared variables. Hope that helped
Dont gain the world and lose your soul
-
Oct 15th, 2002, 10:17 AM
#3
hmm..thought I had tried that before. Ill check again and see if that does it. Thanks.
-
Oct 15th, 2002, 10:19 AM
#4
Actually I think the problem is wanting to share the same object across different exes or AppDomains. You can use remoting to share the same instance or find a way to serialize the object and deserialize it to the other exe. Hopefully I'm wrong though and DevGrp is right or there is an easier way.
-
Oct 15th, 2002, 10:23 AM
#5
I might be mistaken, but I don't believe a dll is shared between applications. It runs in-process.
Your static/shared variable will be visible for one application only.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|