2

What is the modern day equivalent to achieve COM interop type of integration (i.e. for Excel type of automation purposes) between two .NET applications?

For example, if you expose a .NET application API via COM, you are able to get a runtime reference to that application in your COM client and get event callbacks, call methods, etc.

Is there a modern day technology suited for this between two .NET applications? I understand there is .NET Remoting or WCF (i.e. via named pipes) - is there anything newer/better?

TJF
  • 2,248
  • 4
  • 28
  • 43
  • 1
    `COM Interop` is still modern technology. You can use `dynamic` to simplify work with `COM interop`. – Hamlet Hakobyan May 30 '14 at 16:14
  • 1
    I think you answered your own question. WCF is .NET's new COM. COM is still somewhat faster, depending on what you are doing, however, and is still relevant and in modern use. It's also more broadly compatible. – J... May 30 '14 at 16:18
  • ty, if you'd like to make this an answer, I'll go ahead and accept it – TJF May 30 '14 at 18:13

1 Answers1

1

IMO, it would be an overkill to use WCF for communicating between two desktop applications on the same computer.

I'd rather use either ROT or simply RegisterActiveObject/RevokeActiveObject to register the server application object. Then, accordingly, I'd use ROT or GetActiveObject to obtain a COM proxy to this object from the client application.

For communicating, I'd use some standard COM interfaces which COM IPC marshaller can marshal without registering a type library (no need for RegAsm). E.g., IOleCommandTarget or a custom dispinterface (ComInterfaceType.InterfaceIsIDispatch, which maps to a non-dual IDispatch).

Comparable to WCF, this can be done with minimal development efforts and runtime overhead.

noseratio
  • 59,932
  • 34
  • 208
  • 486
  • I honestly don't understand how that is "minimal development" compared to WCF. Is this a troll answer? – Aron Jun 03 '14 at 07:30
  • @Aron: *"Is this a troll answer?"* No. The C# code for what I've described would probably fit into the screen you're looking at. So, is this a troll comment? This is something for you to think about: http://stackoverflow.com/a/22934295/1768303 – noseratio Jun 03 '14 at 07:33
  • So would the equivalent code with ChannelFactory/ServiceHost (I assume we are discounting the interfaces). But the advantage of WCF is there is much less casting. – Aron Jun 03 '14 at 07:35
  • @Aron, so what's exactly the advantage of WCF for communicating between two apps running locally on the same desktop? – noseratio Jun 03 '14 at 07:37
  • My point is that you CLAIM ("Comparable to WCF, this can be done with minimal development efforts and runtime overhead.") its much easier than WCF. Yet COM clearly has its roots in native programming. As for runtime overhead, if it is an issue you should be using MMF. – Aron Jun 03 '14 at 07:43
  • @Aron, I don't CLAIM, note my answer begins with *IMO*. Same as what you stated above is just your own opinion. As to MMF, I doubt you'll beat COM marshaller when you come up with your own MMF + IPC synchronization. I also doubt you'll beat it with WCF + net.pipe bindings. If you like to further challenge this, feel free to post your own answer with some benchmarks, maybe I'll learn something from it. – noseratio Jun 03 '14 at 07:53
  • Speed wise, WCF will always lose...I find its just easier to program (without errors). Better compile time checking. – Aron Jun 03 '14 at 07:55
  • @Aron, I don't see where I'd loose the compile time checking with COM, either. The `ComInterfaceType.InterfaceIsIDispatch` interface is still strictly defined and shared between server and client. There's no reflection or `dynamic` involved here. – noseratio Jun 03 '14 at 08:01
  • Is it not late binding? – Aron Jun 03 '14 at 08:02
  • I think you're confusing COM late binding with .NET reflection. You can declare a late-bound `IDispatch`-based interface in C# with `InterfaceIsIDispatch` and still have compile-type safety. The .NET Interop marshaller seamlessly takes care of the mapping between C# method calls and `IDispatch:Invoke`. The COM marshaller takes care of IPC. – noseratio Jun 03 '14 at 08:09