0

Is there some "new/better" way to open a WPF window and get some return object when it closes than using COM?

Or is it still - in year 2014 - the way to go?

Something like this:

[Guid("14B55D90-E07B-4DC9-B2EE-25F15607518B")]
[ComVisible(true)]
public interface ComInterface
{
    [DispId(0)]
    void ShowWindow();
}

[Guid("CC01974D-82E2-4E9E-A48C-562D3ED83459")]
[ComVisible(true)]
[ClassInterface(ClassInterfaceType.None)]
[ComDefaultInterface(typeof(ComInterface))]

public class ComClass: ComInterface
{
    public void ShowWindow()
    {
        MainWPFWindow window = new MainWPFWindow();
        window.Show();
    }
}
Rand Random
  • 7,300
  • 10
  • 40
  • 88
  • You could use [C++/CLI](http://msdn.microsoft.com/en-us/magazine/cc163852.aspx) for example. Depends on what the "external exe" is. – floele Apr 10 '14 at 18:01
  • @floele The other exe would be a second wpf application and a excel/word addin. – Rand Random Apr 10 '14 at 19:20
  • Well, from a second WPF application you can just reference the other DLL and call whatever classes you like? If the addin is also developed using .NET you can do the same. So why even consider COM? – floele Apr 10 '14 at 20:04
  • @floele I cannot reference to a DLL i need to be able to tell a running exe to open a window and get some values that this instance of the application already holds. – Rand Random Apr 10 '14 at 20:23
  • OK then we are talking about inter process communication. There are many options... .NET remoting, Windows messages, named pipes, etc. If you just want to tell another app to open a Window, a simple SendMessage() will suffice though. – floele Apr 10 '14 at 20:25
  • @floele could you provide some links? For the topics you mentioned. – Rand Random Apr 10 '14 at 20:30

1 Answers1

1

What you are apparently looking for is inter-process communication. With .NET, you have various options, among the following:

Here is another list for IPC methods: Interprocess Communications

Community
  • 1
  • 1
floele
  • 3,668
  • 4
  • 35
  • 51