ok ill try this out..
Printable View
ok ill try this out..
It could be, it is the easies case.
nightscorpion, are mediat.test(4) and mediat.recieveEle(request) called in the same process, or in two separate processes (e.g. windows service and a client application)? If it would be two separate processes, you need more comlex solution, like a one based on WCF.
They are two separate processes....one(A) is a console app and project B is a class library .
so u mean to say i need to have WCF services like an LCS with a config file?
WCF or remoting or any other kind of RPC, because as mentioned before, if there are two different proceses, which means two different app domains they, there are also two different "instances" of the Mediator type (the type is loaded in two different instances of CLR) which doesn't share anything, so the static doesn't work the way you know from case where there is only one process.
Is the guy'z problem sharing and accessing data between two different processes?
I don't think so. He has declared and initialized two separate instances of his class and every instance will have its separate data.
Scorpion! if you want to access A's instance in B, make some public method in B which accepts A's instance and pass it your declared instance.
Correct me someone if I am wrong.
Hey ,
@MNovy : I tried out the code which u sent me..in ur code u could use the instance as a parameter in ur main coz u have created the instance in the same class itself. Whereas in my case one instance is created in main (project A) and the other instance in Project B...AND both are having their references to C. So between A and B there are no references at all.
to be more precise on wht i am working with project A is my host which is a console app AND which also initiates a Workflow instance . Project B is suppose to start the Enterprise Architect and open a Project(when the project is opened it is in the the form of a tree view.). I select an element from the treeview and it should get this workflow instance which was created in my Project A.
To make this more simpler i used a int instead of a workflow instance to make it easier to understand in the forum.
@nabeelisnabeel : as i said both are having their references to Project C it hardly matters if i declare the methods as public ..as they are 3 different projects
i had created the project C coz A and B was creating a circular dependency and also because A is a console app and B a class library.
i have not much info abt WCF..probably it might work out with it.
Where is the problem? You can use the mechanics I mentioned here, too.
Where is B created? In A?
B has to be instantiated somewhere, isn't it?
At this point, just pass the class you want to use there, too.
So you create in A your instance of class C and set all values.
Create instance of B in A (because you want to use it there) and pass the class C directly.
BTW:
Your code design seems to be very, very bad anyway.
If you have to access an instance from other classes, you have to pass either the values by
copying (call by value) them or by reference (call by reference).
Both are explained in my previous code.
Or make that class completely static, then it holds the values directly with no instance.
There is NO other way man.
Redesign your code!!!