Gast
#2877389
Hallo,
ich würde gerne von einem Programm (ConsoleApplication1.exe) aus ein
anderes Programm (ConsoleApplication2.exe) in Form einer EXE als
"Process" starten. Das klappt auch soweit. Allerdings würde ich gerne
von dem gestarteten "Process" aus (ConsoleApplication2.exe) eine Methode
des Programms (ConsoleApplication1.exe) aufrufen, die den "Process"
gestartet hat.
Ich könnte mir vorstellen, dass das mit COM machbar wäre. Allerdings
verstehe ich das nicht ganz, wie ich die Anwendung so registrieren kann,
so dass ich über COM darauf zugreifen kann. Hat hierfür jemand ein
einfaches Beispiel? Funktioniert das aus Visual Studio heraus, oder muss
da vorher immer ein Installer laufen?
Vielen Dank schon jetzt dafür,
Peter
Programm 1:
-----------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
Process proc = new Process();
proc.StartInfo.FileName = "ConsoleApplication2.exe";
proc.Start();
}
public void sayHello()
{
Console.WriteLine("Hello");
}
}
}
Programm 2:
-----------
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
// Pseudo-Code.
Reference ConsoleApplication1;
ConsoleApplication1.Program.sayHello();
// Pseudo-Code Ende.
}
}
}