I have a console application, I've added a new project (form) under the same solution, how would I access variables from the other project and still have 2 executables; one for each.
Asked
Active
Viewed 146 times
0
-
1Just look at this question: http://stackoverflow.com/questions/15174330/how-to-share-variable-between-two-c-sharp-projects – Whencesoever Jun 18 '16 at 17:50
-
1You don't - they would execute in separate processes, so wouldn't have access to each other's variables even if they were both running, which they might not be. It's very unclear what you're trying to achieve, which makes it hard to help you. – Jon Skeet Jun 18 '16 at 17:51
-
Do you mean you want to reuse the variable declarations, or do you want them to share the variables in the sense that if you have both processes running, and one of them change a variable, the other process will see the changed value if it accesses that variable? Please clarify what you want to accomplish. – Lasse V. Karlsen Jun 18 '16 at 17:52
-
A variable is declared is project a, I want project b to be able to read and change the variable. – ArraysRus Jun 18 '16 at 17:55
-
One interpretation of your question could be answered by simply adding a reference to project a in project b. Even though it is an executable, you can still reference like a class library if it has a public api. – Crowcoder Jun 18 '16 at 19:00
-
You need to reference the form by its instance. See my two from project on following posting : http://stackoverflow.com/questions/34975508/reach-control-from-another-page-asp-net – jdweng Jun 18 '16 at 20:34
-
You are talking about two different exes, not the same process if I understood. You CAN read a different process memory content with Kernel32.DLL and OpenProcess / ReadProcessMemory functions by p/Invoke. The problem is WHA to read. Now, the best and reliable solution I think, because playing with memory is a bad bad bad idea, is to create an async FileWatcher, so you can create a file in disk with the variable values and parse them in the other process, and so... That's the easiest solution I think. – c_str Jun 18 '16 at 22:11