0

I tried to use "Microsoft.Office.Interop.PowerPoint" in a simple WPF, but I got an error which was caused by the first line:

Microsoft.Office.Interop.PowerPoint.Application myApp= new Microsoft.Office.Interop.PowerPoint.Application();

The error looks the following way:

An unhandled exception of type 'System.Windows.Markup.XamlParseException' occurred in PresentationFramework.dll

Additional information: Cannot create instance of 'MainWindow' defined in assembly 'PowerPointApp, Version=1.0.0.0, Culture=neutral.

How to fix it? Should I add something to xaml?

Darius Miliauskas
  • 3,391
  • 4
  • 35
  • 53
  • It also throws COMException: A first chance exception of type 'System.Runtime.InteropServices.COMException' occurred in PowerPointApp.exe Additional information: Retrieving the COM class factory for component with CLSID {91493441-5A91-11CF-8700-00AA0060263B} failed due to the following error: 80040154. – Darius Miliauskas Jul 28 '15 at 16:25
  • https://msdn.microsoft.com/query/dev12.query?appId=Dev12IDEF1&l=EN-US&k=k(EHCOM);k(TargetFrameworkMoniker-.NETFramework,Version%3Dv3.5);k(DevLang-csharp)&rd=true – Darius Miliauskas Jul 28 '15 at 16:36

1 Answers1

0

Are you trying to host the PowerPoint UI in WPF?

I once built a document management system that used a WebBrowser control to host PowerPoint within WPF. If you navigate to the pptx file in the WebBrowser control and PowerPoint is installed it will open it.

Here is another, more long-winded method: Embedding-PowerPoint-presentation-player-into-a-WP

If you just want to manipulate the presentation content and not use PowerPoint UI then maybe its another issue. You will need to reference the correct version of the Office interop assemblies as ones built on Office 2007 will not support Office 2010 for example.

Glen Thomas
  • 10,190
  • 5
  • 33
  • 65
  • Thanks! Yes, I knew that link. However, I just want to manipulate the content of the .pptx file, not host for now. Office Interop assemblies targeting Office 2010, I checked. The first sentence caused that error in WPF. How to overcome that error since it is related with that line of code? – Darius Miliauskas Jul 29 '15 at 15:24
  • I changed .NET framework from 3.5 to 4.5; I tried to add references from "Program Files" instead of adding from project folder, it didn't help. – Darius Miliauskas Jul 29 '15 at 16:03