tags:

views:

33

answers:

4

I have a .NET exe that I wrote and it has a couple properties that I made public and want to expose.

I want to shell this exe (Process.Start()) and then somehow reference this exe and get access to these public properties. These properties expose information about the running exe.

I know how to shell to the exe. And I know how to add a reference to the exe from my project that I want to use this object. But how do I get access to the properties of this running exe?

I hope I am explaining myself well.

If you do know the answer maybe you could just tell me what the standard method is to expose properties of a running exe to another application at run-time.

Thanks for any help!

+1  A: 

It does not work that way.

The only ways to share data between processes are pipes (Process.Start() can redirect standard input, standard output, and standard error), shared memory (not available in pure managed code), the exit code, and filesystem or network communications mechanisms.

In your specific case I'd guess that named pipe is the technique you want.

Personally I've never used named pipe but I have used redirect standard input and standard output.

Joshua
A: 

Your EXE can host a WCF service. This service can expose operations (not properties) that can expose this information about the running EXE.

John Saunders
Thanks John, I was kinda thinking that I may need to go this way.
Doug
+1  A: 

Have you considered exposing the objects to PowerShell so that you can call the object from PowerShell?

Expose the object:

   runspace.SessionStateProxy.SetVariable("ObjectName", ObjectName)

Then a PS script could call:

  $ IDLevel.ObjectName

In this object then you could have some simple "getter" methods that would return information about the exe.

I like this approach as not only can you get the info. but if you want, you can expose methods which will allow you to make changes to the object based on the info. returned.

David Relihan
+2  A: 

The standard "Windows way" to do what you describe is to expose PerfMon counters and update them regularly.

Sam Saffron