Using inropservices.powerpoint in windows service - c#-4.0

I have a windows service which activates Interop powerpoint Application class.
It works fine using console but when I try to run it as a windows service on my server (Windows Server 2012) it throws COMException when i use app.open method
When I run the windows service on my pc it also works fine
NOTE: I've installed Microsoft Office 2013 on my server, and added a Desktop folder in C:\Windows\System32\config\systemprofile and in SystemWOW64
Exception details: System.Runtime.InteropServices.COMException: Error HRESULT E_FAIL has been returned from a call to a COM component
Thanks in advance

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.
As a workaround you may consider using the Open XML SDK, see Welcome to the Open XML SDK 2.5 for Office for more information.

Related

MS office Word 2016 upgrade from 2010 resulted in error “error: 80080005 Server execution failed” (CO_E_SERVER_EXEC_FAILURE) .Net web application

.Net C# web application that generates a word document from one of its web page.
In dev server we have recently upgraded the microsoft office version from 2010 to 2016. while initializing word dll running into issues (in one another environment still we have office 2010 installed and we don't see this issue, but the microsoft office upgrade from 2010 to 2016 is mandatory). So i need help to fix this issue.
using Word = Microsoft.Office.Interop.Word;
.....
App wrodApp = new Word.Application(); --> this line causing the below error
Error: Retrieving the COM class factory for component with CLSID {000209FF-0000-0000-C000-000000000046} failed due to the following error: 80080005 Server execution failed (Exception from HRESULT: 0x80080005 (CO_E_SERVER_EXEC_FAILURE)).
Please let me know how to resolve this issue?
Here is what MS states:
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.
You may consider third-party components designed for the server-side execution instead. Or, if you deal with Open XML documents only, you may consider using the Open XML SDK 2.5 for Office.

Error deploying VS 2015 application on server

I am using VS 2015 to create a console application that has a reference to Microsoft.Office.Interop.Excel. When I deploy it on a server (Windows Server 2012) I get the following error:
Retrieving the COM class factory for component with CLSID {0004567-3456-
0000-C002-000434000046} failed due to the following error: 80040154
I read some old postings that suggest I must have Office 2010 installed on the server. However, this is not possible. Is there any way to embed Excel assemblies in my application?
Or is there any different approach to resolve this issue? What I need to do is just extract an Excel file sheet names as a list....
Please remember that you need to have the host application installed on the target machine. When and where do you run the console application on the server?
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.
You may consider using the Open XML SDK if you deal with open XML documents only. See Welcome to the Open XML SDK 2.5 for Office for more information. Or use any third-party components designed for the server-side execution.

What is office runtime? Where is it useful?

I have a .net solution for converting word/excel to pdf developed in MS Visual Studio .Net 2003.I added references i.e., Microsoft.Office.Interop.Excel, Microsoft.Office.Interop.Word in my project. It is working fine in my local system where MS Office is installed but when I tried to execute in the server where MS Office is not installed, I face some Class ID errors 00024500-0000-0000-c000-000000000046 and 000209FF-0000-0000-c000-000000000046 with respect to Word and excel. So i told my client to install MS Office on server but he wants me to use Office runtime 2010 to convert MS office documents? So what is office runtime actually? Was it helpful in my case? Does MS Office installation is required if I am using VSTO?
I am new here. Kindly help.
Thanks,
Praveen.
There is no "Office runtime".
I added references i.e., Microsoft.Office.Interop.Excel, Microsoft.Office.Interop.Word in my project.
Interop assemblies are used to marshal your calls into unmanaged environment. There is no actual COM servers installed that may handle your calls (i.e. no endpoints).
Anyway, 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. You can read more about that in the Considerations for server-side Automation of Office article.
If you deal only with open XML documents you can use the Open XML SDK. See Welcome to the Open XML SDK 2.5 for Office for more information.
But if you need to deal with binary file formats you have to look for third-party components that are designed for the server-side execution.

Installing Microsoft Office on a windows server?

I could not google a straight simple answer to this, so i'm trying my luck here.
is there a problem installing Microsoft office 2007\2010\2013 on a network windows-based server, to be able to do some server-side conversions and simple automatic operations using its inter ops libraries on user generated documents?
If it is, is there anything i need to know prior to installing it ? any licenses needed ? cost of these ? is it the same as installing office on a client pc ?
Thanks in advance.
Microsoft Office supports Windows Server OS - feel free to install it on your server. But it doesn't support automation on the Server server side. The Considerations for server-side Automation of Office page states the following:
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.
Developers can use Automation in Microsoft Office to build custom solutions that use the capabilities and the features that are built into the Office product. Although such programmatic development can be implemented on a client system with relative ease, a number of complications can occur if Automation takes place from server-side code such as Microsoft Active Server Pages (ASP), ASP.NET, DCOM, or a Windows NT service.

open word document when running service

I have written the following statement to open the word document.
<!-- language: lang-c -->
System.IO.Directory.CreateDirectory("D:\\urvashi");
objMyDoc = ApObj.Documents.Open(filename, MsoTriState.msoTrue, MsoTriState.msoTrue, MsoTriState.msoFalse);
System.IO.Directory.CreateDirectory("D:\\komal");
It is working fine when I am checking it by debugging the code, but when running this code through the service it is not working properly.
It is creating directory "urvashi" in D drive but it is not creating directory "komal" in D drive.
The error is in the second statment when running service; what could be the problem?
"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."
http://support.microsoft.com/kb/257757/en-us?fr=1
Office application can run in interactive mode not in service mode. so it is not advisable open any office documents in services / server side programs.

Resources