How to Most Effectively use C#.NET to communicate with COM Objects? RRS feed

  • Question

  • I've been given a task to write a series of C#.NET apps to communicate with a software product's COM objects.  I've never done something like this before so naturally searched the Internet for tips & tricks on how to do so.  I did find some general information but nothing of a "best practices" or "do's & don'ts".

    My employer has tried the same a little in the past but found the communication to be extremely slow.  I'm hoping there might be someone on here who has successfully done this before and would kindly offer some valuable tips on how to do it in the most effective way possible.

    Thank you!

    Robert Werner
    Friday, June 6, 2014 7:31 PM


All replies

  • I suggest you to get a profiler to find out where the bottleneck is. Also how does the COM object performance in native code?  If the COM object itself is slow there's not much you can do about it.

    Visual C++ MVP

    Sunday, June 8, 2014 1:18 AM
  • Thank you for this!

    Can you recommend a URL or two that would provide some Best Practices about communicating between .NET and COM objects?

    Sunday, June 8, 2014 1:29 AM
  • Not about COM but if your COM object is written in native code, check

    Chapter 7 — Improving Interop Performance

    If your COm object is written in managed code, it is better to not use COM to talk to it. 

    Visual C++ MVP

    Sunday, June 8, 2014 2:58 AM
  • http://msdn.microsoft.com/en-us/library/ms973800.aspx gives a very good overview about using COM from .Net.

    Regarding the slowness that you are mentioning, am sure it is specific to what you are doing in the COM components. If you can provide some more details about what gets slowed down, we might be able to help.

    Monday, June 9, 2014 12:40 PM