1

I have another program executable which I have added as a reference in my C# file. Right now I'm currently transitioning to that program by using it's namespace followed by the first class to instantiate a object, then I am simply just showing that instance, i.e:

// Instantiate next screen using the namespace and accessing the first class
myProg.MainWindow myProgInst = new myProg.MainWindow();

// Call myProg
myProgInst.ShowDialog();

My question is, instead of opening a new window - is there a way I can actually send the instance of memory from myProg to the program calling it so that the elements of the object will just transition to the window of the program calling it? Essentially I am trying to eliminate the opening of a new window if I can just throw the other programs information into the one calling it. Maybe you can't do this, just thought I'd ask.

Thanks in advance

Ehsan Sajjad
  • 61,834
  • 16
  • 105
  • 160
  • 1
    please, show code where you send data to another program. – StepUp May 10 '16 at 14:25
  • 1
    *"send the instance of memory from myProg to the program calling it so that the elements of the object will just transition to the window of the program calling it"* - are you talking about inter-process communications (IPC) ? Or a simple command-line parameters (arguments)? – Sinatr May 10 '16 at 14:25
  • @StepUp I'm asking how to do that. Sinatr, It may be a form of that, though I am not familiar what that is. –  May 10 '16 at 14:27
  • 1
    You can [return result](http://stackoverflow.com/q/1585354/1997232) from another process (or result, if its more than a simple `int`, can be passed via file, which name in turn is passed as command-line parameter to `myProg`). See more about [IPC](https://msdn.microsoft.com/en-us/library/windows/desktop/aa365574(v=vs.85).aspx). – Sinatr May 10 '16 at 14:30
  • Interesting, thank you! –  May 10 '16 at 14:36

2 Answers2

1

you can use "ref" to send object by reference in c#. create a method like this in other program and call this from myProg class.

//example
void Test (ref ClassName myProg)
{

}

This function will not create a new object of the class instead it will pass the same object by reference.

I hope this is what you are asking for.

Nabeel Zafar
  • 191
  • 10
0

You could make a TCP connection between them, both need a TCPlistener and a TCP client. Here you can see a tutorial.

Also, you can use Named Pipes for Network Interprocess Communication See this tutorial.

StepUp
  • 36,391
  • 15
  • 88
  • 148