views:

82

answers:

3

Hi,

I have a simple WPF application which is already running. Can i access its objects like properties using reflection? So that i can use these object to do some operations like click on button or entering text in text box in the already running application. Thanks in advance.

Akash Kansal.

+3  A: 

From you question I get the impression that you perhaps want to test or in some other way automate a WPF application. This can be done Using UI Automation for Automated Testing.

Martin Liversage
A: 

i think Martin correctly ascertained the crux of your issue, but for the run time reflection question, the answer is yes. Reflection isn't only for instantiating and loading modules. It has plenty of utility for runtime execution of code.

Paul Sasik
+1  A: 

I think he's asking something else. He's asking if you can get instantiated objects in a different process using reflection. So in process A, I have...

ArrayList<string> Foo = new ArrayList<string();
Foo.Add("I'm a Foo");

... in process B, is there any way he can call Foo.Clear(), assuming that process A doesn't explicitly open a channel for him to do so.

If that's the case, I'd say the answer is an emphatic "NO". This would be a huge security issue.

If, on the other hand like other people suspect, you are trying to automate entry on another application (either for testing purposes or as part of some "helpful" app), there are approaches for those.

Hounshell