Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Passing a reference of a running exe to another exe
Message
Information générale
Forum:
ASP.NET
Catégorie:
Autre
Divers
Thread ID:
00772357
Message ID:
00772571
Vues:
5
Rick,

You can always break apart your app into different projects and still keep them in the same solution. If you break apart your app into different solutions then you will need to use remoting. Here is an article that explains how remoting works:

http://www.developer.com/net/cplus/article.php/1479761

Also here is some code about how to use remoting to send a message from one form in an exe to another form in another exe. This sample tells the form to maximize itself:

Put this code in a separate class library:
namespace myremote
{
 public delegate void NotifyMainForm (string command);
 class FormManipulateObject : MarshalByRef
 {
    public event FormEventHandler InvokeHostForm;

    public FormManipulateObject()
    {
    }

    public void MaximizeForm()
    {
       if (InvokeHostForm != null)
          InvokeHostForm("Maximize");
    }
 }
}
Now inside of the Host form (or the one you want to maximize. You set up the remote object:
(you can place this in the main form's on_load method)
TcpChannel tcp = new TcpChannel(3000);
ChannelServices.RegisterChannel(tcp);
blah.FormManipulateObject myObj = new 
blah.FormManipulateObject();
blah.FormEventHandler += new blah.NotifyMainForm
(OnFormMsg);
RemotingServices.Marshal(myObj, "MyObj");
(Remember, "myremote" is the name of the namespace where the object was created)

Now make a method called OnFormMsg
private void OnFormMsg(string msg)
{
   if (msg.Equals("Maximize"))
      // code to maximize window 
}
Now just setup the client to use this object:
myremote.FormManipulateObject fmo = 
(myremote.FormManipulateObject) Activator.GetObject(typeof
(myremote.FormManipulateObject), "tcp://localhost:3000/MyObj");
now when your client does fmo.Maximize, an event will be triggered in the other app's form, and it should maximize.



>Can a running exe call another exe and pass a reference of itself to the called exe?
>
>I have a solution that has become so large, that I am inclined to develop future modules as separate solutions (exe's). i want to be able to refresh data from the calling exe when I am disposing the called exe. I want to be able to call my refresh data subroutine in the calling exe when I'm disposing the called exe. Does anyone know if this is possible?
-----------------------------------------

Cathi Gero, CPA
Prenia Software & Consulting Services
Microsoft C# / .NET MVP
Mere Mortals for .NET MVP
cgero@prenia.com
www.prenia.com
Weblog: blogs.prenia.com/cathi
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform