none
Excel automation in windows service

    Question

  • I just finished with excel automation on my windows console application and it works. Now i want to move it to windows service, but i faced an error, which dont kno how to solve. When i run my application i get this error in my log file:

    System.Runtime.InteropServices.COMException (0x8001010A): The message filter indicated that the application is busy. (Exception from HRESULT: 0x8001010A (RPC_E_SERVERCALL_RETRYLATER))
       at System.RuntimeType.InvokeDispMethod(String name, BindingFlags invokeAttr, Object target, Object[] args, Boolean[] byrefModifiers, Int32 culture, String[] namedParameters)
       at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
       at Microsoft.VisualBasic.CompilerServices.VBBinder.InvokeMember(String name, BindingFlags invokeAttr, Type objType, IReflect objIReflect, Object target, Object[] args, String[] namedParameters)
       at Microsoft.VisualBasic.CompilerServices.LateBinding.LateGet(Object o, Type objType, String name, Object[] args, String[] paramnames, Boolean[] CopyBack)
       at Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateGet(Object Instance, Type Type, String MemberName, Object[] Arguments, String[] ArgumentNames, Type[] TypeArguments, Boolean[] CopyBack)

    I heard that it could be a problem to run it from windows service but i do not belive cannot be done. Please of your support.

    From console application everything works just fine. When it comes to windows service immediately after excel code starts i get the above error.

    Wednesday, April 12, 2017 9:54 AM

Answers

All replies

  • Running Office apps from services or non-interactive applications is not supported because of limitations in the threading model.

    Considerations for server-side Automation of Office


    Paul ~~~~ Microsoft MVP (Visual Basic)

    Wednesday, April 12, 2017 11:57 AM
  • Excel requires a Desktop instance to operate correctly so cannot be run correctly from a Service. 

    Reed Kimble - "When you do things right, people won't be sure you've done anything at all"

    Wednesday, April 12, 2017 11:59 AM
    Moderator
  • Beat me to it and found the link!  :)

    Reed Kimble - "When you do things right, people won't be sure you've done anything at all"

    Wednesday, April 12, 2017 12:00 PM
    Moderator
  • I would suggest looking at Spreadsheet Light which does not require Excel. I've used this in a Windows server app without any issues.


    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Wednesday, April 12, 2017 12:24 PM
    Moderator
  • Hi JimmyJimm,

    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 behaviour and/or deadlock when Office is run in this environment. 

    More detailed info, please refer to

    http://www.timwappat.info/post/2013/09/03/Solution-to-Excel-Automation-VBNETC-error-running-as-a-service-0x800A03EC-MicrosoftOfficeInteropExcelWorkbooksOpen

    Best Regards,

    Cherry Bu     


    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.

    Thursday, April 13, 2017 9:42 AM
    Moderator
  • I agree that using automation is not wise which is why I made a suggestion for Spreadsheet Light which under the covers uses Office Open XML format.

    Please remember to mark the replies as answers if they help and unmark them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.
    VB Forums - moderator
    profile for Karen Payne on Stack Exchange, a network of free, community-driven Q&A sites

    Thursday, April 13, 2017 10:24 AM
    Moderator