1

I am uploading PPT files where i am converting ppt silde into images.When i am running in visual studio its working fine but when i am Publising the code to IIS server i am getting Following Error

Retrieving the COM class factory for component with CLSID {91493441-5A91-11CF-8700-00AA0060263B} failed due to the following error: 80070005 Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED)).

Code For This :

Microsoft.Office.Interop.PowerPoint.Application PowerPoint_App = new Microsoft.Office.Interop.PowerPoint.Application();
Microsoft.Office.Interop.PowerPoint.Presentations multi_presentations = PowerPoint_App.Presentations;
Microsoft.Office.Interop.PowerPoint.Presentation presentation = multi_presentations.Open(filePath, MsoTriState.msoFalse, MsoTriState.msoFalse, MsoTriState.msoFalse);
Neeraj Mehta
  • 1,675
  • 2
  • 22
  • 45
  • 1
    Possible duplicate of [What is required server-side to run Office Interops?](http://stackoverflow.com/questions/26224066/what-is-required-server-side-to-run-office-interops) – Lex Li Oct 14 '15 at 07:35
  • https://support.microsoft.com/en-us/kb/257757 Stop wasting time on that and follow Microsoft's recommendations on Office server side automation. – Lex Li Oct 14 '15 at 07:36
  • 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. https://support.microsoft.com/en-us/kb/257757 – gsharp Oct 14 '15 at 07:38

4 Answers4

4

None of the answers on web worked for me for the same issue on Windows Server 2012 R2 (Azure). Here's the narrowed down solution which worked on all the servers.

  1. Installed Office and activated the product on every servers
  2. Created a folder 'Desktop' at C:\Windows\SysWOW64\config\systemprofile\Desktop (64 bit OS) enter image description here
  3. In IIS changed ApplicationPool identity from 'ApplicationPoolIdentity' to 'LocalSystem'. enter image description here

That's it and i was able to convert slides into images.

Source Code

In case you are interested in code that I was using:

Application pptApplication = new Application();
Microsoft.Office.Interop.PowerPoint.Presentation pptPresentation = pptApplication.Presentations.Open2007(Server.MapPath("~/tempslides/pptfilename.pptx"), MsoTriState.msoFalse, MsoTriState.msoFalse, MsoTriState.msoFalse);
List<string> files = new List<string>();
for (int i = 1; i <= pptPresentation.Slides.Count; i++)
{
    pptPresentation.SaveCopyAs(serverPath + randomId, PpSaveAsFileType.ppSaveAsPNG, MsoTriState.msoTrue);
    files.Add(Server.MapPath("~/tempslides") + "/slide" + i + ".PNG");
}
pptPresentation.Close();

To run above code, you need to add reference to interop lib in your project. enter image description here

Hope this helps you to save your time.

Abhimanyu
  • 2,173
  • 2
  • 28
  • 44
2

Configure DCOM

  1. Go to Start -> Run.

  2. Type DCOMCNFG. (This will load the "Component Services")

  3. Go to Component Services -> Computers -> My Computer -> DCOM Config -> Microsoft Office Power point

  4. Right click and select Properties.

  5. Select the Security tab.

In Launch and Activate Permissions

  1. select Customize and press the Edit button.
  2. Press Add button to select the "Network Service" account.
  3. Give permission to Local Launch and Local Activation Click the OK button, and then test your application, it should work fine now.
Krsna Kishore
  • 8,233
  • 4
  • 32
  • 48
0

You should give permissions to "This User" and then get login credentials in COM+ settings.

SHM
  • 1,896
  • 19
  • 48
0

I have followed the below actions to resolve the issue.

1) Go to Control Panel - > Administrative Tools - > Component Services -> Computers -> My Computer -> DCOM Config -> Microsoft Office Power point Right click and select Properties. Select the Security tab. and Provided the full Access to IIS_IUSR for all the three access for Launch and Activate Permissions , Access Permission and Configuration Permission.

2) Set the Application Pool Identity as "LocalSystem"

3) Provide Full Access to IIS_IUSR for the folder where the Microsoft.Office.Interop Dll deployed

Eg : C:\Program Files (x86)\Microsoft Visual Studio 12.0\Visual Studio Tools for Office\PIA\Office15

Suhas Dhongade
  • 79
  • 2
  • 12