none
Windows services can't used Interop that is true ? RRS feed

  • Question

  • Dear All,

    For my research, i know that windows services can't used Interop for the follow link :

    http://stackoverflow.com/questions/13479164/office-interop-does-not-work-in-windows-service

    I want to make sure it,can any one get me some detail about this or solve the issue below :

    I write an tool to save the PowerPoint slide to image,

    you can refer to : http://stackoverflow.com/questions/2972263/ppt-slides-to-images

    and it work fine if i start it with an console project.

    but when i change it to an windows services , i found that it can't work any more.

    the error message :

    System.Runtime.InteropServices.COMException (0x80004005): PowerPoint could not open the file.
       in Microsoft.Office.Interop.PowerPoint.Presentations.Open(String FileName, MsoTriState ReadOnly, MsoTriState Untitled, MsoTriState WithWindow)


    Thursday, May 28, 2015 9:25 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.

    If you are building a solution that runs in a server-side context, you should try to use components that have been made safe for unattended execution. Or, you should try to find alternatives that allow at least part of the code to run client-side. If you use an Office application from a server-side solution, the application will lack many of the necessary capabilities to run successfully. Additionally, you will be taking risks with the stability of your overall solution.

    Read more about that in the Considerations for server-side Automation of Office article. 

    Consider using any third-party components designed for the server-side execution. Or simply you may consider using the Open XML SDK. See  OpenXML PowerPoint Generation also.


    Thursday, May 28, 2015 9:54 AM
  • <<But office 2003 and below with extension .PPT also can used Open XML SDK ?>>

    When Office 2007, with the new file formats, was released Microsoft also supplied a "Compatibility Pack" for Office 2000 - 2003 which can open the new file formats. If automatic updates were activated for an installation, the pack was installed automatically. Where this was not the case, it can be downloaded and installed separately. So Office 2003 CAN open PPTX, as long as the converters have been installed. But not all the functionality in the PPTX may be available - anything new in the later version of PowerPoint that has been included in the file will not work the same way. (Mostly, you get a static picture instead of whatever-it-was.)


    Cindy Meister, VSTO/Word MVP, my blog

    Friday, May 29, 2015 5:37 PM
    Moderator

All replies

  • 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.

    If you are building a solution that runs in a server-side context, you should try to use components that have been made safe for unattended execution. Or, you should try to find alternatives that allow at least part of the code to run client-side. If you use an Office application from a server-side solution, the application will lack many of the necessary capabilities to run successfully. Additionally, you will be taking risks with the stability of your overall solution.

    Read more about that in the Considerations for server-side Automation of Office article. 

    Consider using any third-party components designed for the server-side execution. Or simply you may consider using the Open XML SDK. See  OpenXML PowerPoint Generation also.


    Thursday, May 28, 2015 9:54 AM
  • Hi, Eugene !

    Thanks for your quick reply!

    For all i know, office 2007 and after with extension .PPTX is build with XML .

    But office 2003 and below with extension .PPT also can used Open XML SDK ?

    Friday, May 29, 2015 3:18 AM
  • <<But office 2003 and below with extension .PPT also can used Open XML SDK ?>>

    When Office 2007, with the new file formats, was released Microsoft also supplied a "Compatibility Pack" for Office 2000 - 2003 which can open the new file formats. If automatic updates were activated for an installation, the pack was installed automatically. Where this was not the case, it can be downloaded and installed separately. So Office 2003 CAN open PPTX, as long as the converters have been installed. But not all the functionality in the PPTX may be available - anything new in the later version of PowerPoint that has been included in the file will not work the same way. (Mostly, you get a static picture instead of whatever-it-was.)


    Cindy Meister, VSTO/Word MVP, my blog

    Friday, May 29, 2015 5:37 PM
    Moderator