Search Unity

Microsoft.Office.Interop.PowerPoint not working in build (win standalone)

Discussion in 'Scripting' started by zyzyx, Aug 8, 2018.

  1. zyzyx

    zyzyx

    Joined:
    Jul 9, 2012
    Posts:
    227
    Hi,
    I'm trying to get Microsoft.Office.Interop.PowerPoint working in Unity 2017.4.8 (.NET 4.5). It works fine in the Editor but when I do a standalone build the app crashes and I get the following error:

    Code (CSharp):
    1. System.Runtime.InteropServices.COMException (0x80080005)
    2.   at System.Runtime.InteropServices.Marshal.ThrowExceptionForHR (System.Int32 errorCode) [0x0000a] in <cfc149f8218b496788d8493c87de777a>:0
    3.   at System.__ComObject.CreateIUnknown (System.Type t) [0x00058] in <cfc149f8218b496788d8493c87de777a>:0
    4.   at Mono.Interop.ComInteropProxy.CreateProxy (System.Type t) [0x00000] in <cfc149f8218b496788d8493c87de777a>:0
    5.   at System.Runtime.Remoting.RemotingServices.CreateClientProxyForComInterop (System.Type type) [0x00000] in <cfc149f8218b496788d8493c87de777a>:0
    6.   at System.Runtime.Remoting.Activation.ActivationServices.CreateProxyForType (System.Type type) [0x0003b] in <cfc149f8218b496788d8493c87de777a>:0
    7.   at (wrapper managed-to-native) System.Object:__icall_wrapper_ves_icall_object_new_specific (intptr)
    8.   at OpenPowerpoint.Start () [0x0000a] in <dbcca54dd3c442e696fa6b08b2b32328>:0


    Any help would be greatly appreciated!
     
  2. Fido789

    Fido789

    Joined:
    Feb 26, 2013
    Posts:
    343
    As far as I know using office libraries requires Office to be installed on target device, are you aware of that?
     
    FernandoHC likes this.
  3. zyzyx

    zyzyx

    Joined:
    Jul 9, 2012
    Posts:
    227
    Yes, office is installed. Otherwise it would not work in the editor either, no?
     
  4. lordofduct

    lordofduct

    Joined:
    Oct 3, 2011
    Posts:
    8,531
    What library are you using to interop with PowerPoint?

    Can you show us the offending code?

    Is this taking from the output_log.txt file? Can you show the entire thing?

    Have you built your game with the 'Development' option flagged and then connected it to the debugger and stepped through the code that way?
     
  5. Joe-Censored

    Joe-Censored

    Joined:
    Mar 26, 2013
    Posts:
    11,847
    Might be relevant:

    https://social.msdn.microsoft.com/F...powerpoint-crashing-build?forum=officegeneral

     
  6. zyzyx

    zyzyx

    Joined:
    Jul 9, 2012
    Posts:
    227
    Here is the basic setup:
    Four dlls:
    Microsoft.Office.Interop.PowerPoint.dll (from nuget)
    Microsoft.Vbe.Interop.dll (from C:\Windows\assembly)
    Office.dll (from C:\Windows\assembly)
    stdole.dll (also from C:\Windows\assembly)

    Code for testing:
    Code (CSharp):
    1. using System;
    2. using System.IO;
    3. using Microsoft.Office.Interop.PowerPoint;
    4. using UnityEngine;
    5. using Microsoft.Office.Core;
    6.  
    7. public class OpenPowerpoint : MonoBehaviour
    8. {
    9.     public string FilePath;
    10.     private Presentation Pres;
    11.  
    12.     // Use this for initialization
    13.     void Start ()
    14.     {
    15.         var App = new ApplicationClass();
    16.  
    17.         var path = Path.Combine(UnityEngine.Application.streamingAssetsPath, FilePath);
    18.         Pres = App.Presentations.Open(path, MsoTriState.msoTrue, MsoTriState.msoFalse, MsoTriState.msoTrue);
    19.  
    20.         App.ActivePresentation.SlideShowSettings.Run();
    21.     }
    22.  
    23.     private void Update()
    24.     {
    25.         if (Input.GetKeyDown(KeyCode.RightArrow))
    26.         {
    27.             Pres.SlideShowWindow.View.Next();
    28.         }
    29.  
    30.         if (Input.GetKeyDown(KeyCode.LeftArrow))
    31.         {
    32.             Pres.SlideShowWindow.View.Previous();
    33.         }
    34.     }
    35. }
    Works in editor but crashes at
    var App = new ApplicationClass();

    Yes the error is from the output_log.txt.
    I tried connecting the debugger, but there is not much to step through.
     

    Attached Files:

  7. zyzyx

    zyzyx

    Joined:
    Jul 9, 2012
    Posts:
    227
  8. svanderbeck

    svanderbeck

    Joined:
    Oct 23, 2017
    Posts:
    17
    I am running into something similar. Did you ever figure out a solution for this?
     
  9. zyzyx

    zyzyx

    Joined:
    Jul 9, 2012
    Posts:
    227
    I ended up writing a separate .net console application and starting it via Process(). Communication was done using sockets (UDP).
     
  10. yugosaito4

    yugosaito4

    Joined:
    May 9, 2019
    Posts:
    4
    hi @zyzyx may i know if u are able to extract powerpoint slides from the editor
     
  11. yugosaito4

    yugosaito4

    Joined:
    May 9, 2019
    Posts:
    4
    did u find anything