C# Reflection on already running process

Brian Dumas
Brian Dumas used Ask the Experts™
on
Hello All,

I have two C# WinForm applications. When BOTH apps are running, I would like to use reflection in App A to get and set information in App B. I can do this already if App A uses refelection to load the App B assembly. Is there anyway to do the same if App B is already running?

Also, when I use reflection in App A to Load the App B Assembly, is App B still running in its own process? I don't see it in task manager, but I do see it on the desktop

Both App A and App B are forms
Windows 7 Pro 64
VS2013

Thanks very much,

Brian
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
the way i do it is get the process memory address from the kernel32,
and get the info you need and r/w that address to the b app the same way but reversed.
Miguel OzSenior Software Engineer
Top Expert 2009
Commented:
I do not think you can do this using reflection, you need to share information in a different way, some examples:
1. A file.
2.  A database table or tables.
3.  Inter process communication
4.  Web services (SOA, Web API)
Depending on your needs usually 1 and 2 will do the trick.
kaufmedGlanced up at my screen and thought I had coded the Matrix...  Turns out, I just fell asleep on the keyboard.
Most Valuable Expert 2011
Top Expert 2015

Commented:
Agree with Miguel Oz, but I'd also add that perhaps the WinAPI could be used here as well...though it's more difficult to work with than the other suggestions.
Brian DumasSenior Software Engineer

Author

Commented:
Hello all, I am aware that I can use multiple number of ways to do IPC. What I needed in the beginning was a C# way of creating objects in App B. I have reflection working at this time that does just that, but it needs to 'start' App B for it to work. Just curious as to any method to do the same thing as I am doing now, without starting AppB (since in the actual environment App B will be running).

Thanks
Miguel OzSenior Software Engineer
Top Expert 2009

Commented:
As per my post, the answer you can not do it with reflection, you shall use one of the IPC based suggested solutions.
 "when I use reflection in App A to Load the App B Assembly, is App B still running in its own process?"
 No, APP B  is running in App A process, thus the reason you can access all their values in your current code, if it is a separate process then it is not possible
Brian DumasSenior Software Engineer

Author

Commented:
Disagree with 'force accept', but not my decision.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial