none
Interaction with external (WCF) process RRS feed

  • Question

  • I would like to communicate with Excel to/from an external .Net process, initiated by user actions on Excel (e.g. menu clicks).

    What I did so far is to make a class library which is registered for COM Interop, adding COMVisible attributes, GUID attributes, DispID attributes etc. and called this component from VBA. So far so good.

    Next step I did was making a self hosted WCF service (this case by a console exe) offering some methods which is callable from the COM components (which runs in the Excel process).

    One service method is called asynchroneously as e.g. "await theService.DoWorkAsync()" and on the service side I try "Marshall.GetActiveObject("Excel.Application"), but this fails with the message
    System.Runtime.InteropServices.COMException: 'Operation unavailable (Exception from HRESULT: 0x800401E3 (MK_E_UNAVAILABLE))'

    I want the COM component to be as small/thin as possible, basically just dispatching methods to the wcf service which in turn works with excel out-of-process.
    Is there a better way of handling this?


    • Edited by EuroEager Monday, October 30, 2017 7:47 PM Mistake
    Monday, October 30, 2017 10:29 AM

Answers

  • Hello,

    Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when Office is run in this environment.

    Please visit Considerations for server-side Automation of Office for more information.

    I suggest you automate Office in your previous project instead of WCF service.

    Regards,

    Celeste


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by EuroEager Tuesday, October 31, 2017 6:52 AM
    Tuesday, October 31, 2017 6:30 AM
    Moderator

All replies

  • Seems like service crashed due to running as admin (in debug mode) while Excel runs without elevation.

    Does that make sense ?

    Monday, October 30, 2017 7:49 PM
  • Hello,

    Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when Office is run in this environment.

    Please visit Considerations for server-side Automation of Office for more information.

    I suggest you automate Office in your previous project instead of WCF service.

    Regards,

    Celeste


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    • Marked as answer by EuroEager Tuesday, October 31, 2017 6:52 AM
    Tuesday, October 31, 2017 6:30 AM
    Moderator