none
Power Point 2013 opens second windows if open presentation while doing wait in add-in RRS feed

  • Question

  • 1. Start power point 2013 and wait for initialization in console application.

    2. Attach to COM object of Power Point.

    3. Open presentation.

            static void Main(string[] args)
            {
                var startInfo = new ProcessStartInfo(@"C:\Program Files (x86)\MSOffice\Office15\powerpnt.exe");//32 bit PPT
                startInfo.UseShellExecute = false;
                Process.Start(startInfo);
                Application ppt = null;
                while (ppt == null)
                {
                    try
                    {
                        System.Threading.Thread.CurrentThread.Join(500);
                        ppt = (Application)Marshal.GetActiveObject("PowerPoint.Application.15");
                    }
                    catch
                    {
                        ppt = null;
                    }
                }
                Console.WriteLine(ppt.Version);
                ppt.Presentations.Open(System.IO.Path.Combine(Environment.CurrentDirectory, "PPT_simple_2013.pptx"));
                Console.ReadKey();
            }

    4.  Ensure there is only one VSTO add-in which does next upon Power Point start. And does next:

      private void ThisAddIn_Startup(object sender, System.EventArgs e)
            {
                var secondWindowMaker = new ManualResetEvent(false);
                secondWindowMaker.WaitOne(1000);
            }

    Expected: Only one window of Power Point is opened.

    Actual: 2 windows are opened. One with presentation. Another one is empty.

    Notes:

    There is no issue when there is no add-in.

    There is no issue when Thread.Sleep(1000) instead of wait.

    Issue is reproduced when only sample add-in is loaded. Attached modules dump to check. 

    Issue is root cause for bug in our production scenario when one process automates Power Point 2013 and Power Point add-in waits for some initialization to finish upon start.

    Issue was easily reproduced on:

    1. Windows 7 64 bit Power Point Pro 2013 32 bit.

    2. Windows 8.1 64 bit Power Point Pro 2013 64 bit.

    Attached Visual Studio 2010 VSTO solution via next link:

    https://drive.google.com/file/d/0B2JxOi1f9p2zeTljZjhyUDh6Y3M/edit?usp=sharing

    1. Open OpenWaitPpt2013.VS2010.sln and build

    2. Run PowerPointOpen.exe or project of console.

    3. PPT_simple_2013.pptx is sample dummy presentation.

    The same reproduced using COM Shim.

    ADAL.DLL, 0x61c00000, 724 kB, Windows Azure Active Directory Authentication Library
    advapi32.dll, 0x750f0000, 640 kB, Advanced Windows 32 Base API
    api-ms-win-downlevel-advapi32-l1-1-0.dll, 0x75af0000, 20 kB, ApiSet Stub DLL
    api-ms-win-downlevel-advapi32-l2-1-0.dll, 0x71bc0000, 16 kB, ApiSet Stub DLL
    api-ms-win-downlevel-normaliz-l1-1-0.dll, 0x76d10000, 12 kB, ApiSet Stub DLL
    api-ms-win-downlevel-ole32-l1-1-0.dll, 0x74c90000, 16 kB, ApiSet Stub DLL
    api-ms-win-downlevel-shlwapi-l1-1-0.dll, 0x75b00000, 16 kB, ApiSet Stub DLL
    api-ms-win-downlevel-user32-l1-1-0.dll, 0x76d40000, 16 kB, ApiSet Stub DLL
    api-ms-win-downlevel-version-l1-1-0.dll, 0x75e50000, 16 kB, ApiSet Stub DLL
    apisetschema.dll, 0x40000, 4 kB, ApiSet Schema DLL
    apphelp.dll, 0x5c1f0000, 304 kB, Application Compatibility Client Library
    bcrypt.dll, 0x73590000, 92 kB, Windows Cryptographic Primitives Library (Wow64)
    bcryptprimitives.dll, 0x73550000, 244 kB, Windows Cryptographic Primitives Library
    cfgmgr32.dll, 0x75e20000, 156 kB, Configuration Manager DLL
    clbcatq.dll, 0x74e00000, 524 kB, COM+ Configuration Catalog
    clr.dll, 0x708a0000, 6.61 MB, Microsoft .NET Runtime Common Language Runtime - WorkStation
    clrjit.dll, 0x6ae80000, 500 kB, Microsoft .NET Runtime Just-In-Time Compiler
    comctl32.dll, 0x70730000, 528 kB, User Experience Controls Library
    comctl32.dll, 0x73c80000, 1.62 MB, User Experience Controls Library
    counters.dat, 0x3fa0000, 4 kB, 
    credssp.dll, 0x6ae50000, 32 kB, Credential Delegation Security Package
    crypt32.dll, 0x757b0000, 1.13 MB, Crypto API32
    cryptbase.dll, 0x74b60000, 48 kB, Base cryptographic API DLL
    cryptnet.dll, 0x53110000, 112 kB, Crypto Network Related API
    cryptsp.dll, 0x74030000, 88 kB, Cryptographic Service Provider API
    cscapi.dll, 0x71660000, 44 kB, Offline Files Win32 API
    C_1252.NLS, 0x3b50000, 68 kB, 
    C_1255.NLS, 0x51d0000, 68 kB, 
    d2d1.dll, 0x63580000, 3.28 MB, Microsoft D2D Library
    d2d1.dll.mui, 0x5940000, 200 kB, Microsoft D2D Library
    d3d10warp.dll, 0x50e70000, 1.91 MB, Direct3D 10 Rasterizer
    d3d10_1.dll, 0x5cc20000, 176 kB, Direct3D 10.1 Runtime
    d3d10_1core.dll, 0x77900000, 260 kB, Direct3D 10.1 Runtime
    d3d11.dll, 0x51060000, 1.46 MB, Direct3D 11 Runtime
    detoured.dll, 0xf000000, 24 kB, 
    devobj.dll, 0x754e0000, 72 kB, Device Information Set DLL
    dfshim.dll, 0x9ef0000, 1.09 MB, ClickOnce Application Deployment Support Library
    dfshim.dll.mui, 0x4430000, 20 kB, ClickOnce Application Deployment Support Library
    dhcpcsvc.dll, 0x738e0000, 72 kB, DHCP Client Service
    dhcpcsvc6.dll, 0x73730000, 52 kB, DHCPv6 Client
    dnsapi.dll, 0x6a370000, 272 kB, DNS Client API DLL
    dwmapi.dll, 0x6eb80000, 76 kB, Microsoft Desktop Window Manager API
    DWrite.dll, 0x6b160000, 1.21 MB, Microsoft DirectX Typography Services
    dxgi.dll, 0x62060000, 304 kB, DirectX Graphics Infrastructure
    dxgidebug.dll, 0x62040000, 112 kB, DXGI Debug Binary
    FWPUCLNT.DLL, 0x736f0000, 224 kB, FWP/IPsec User-Mode API
    gdi32.dll, 0x76ab0000, 576 kB, GDI Client DLL
    GdiPlus.dll, 0x6e9f0000, 1.56 MB, Microsoft GDI+
    gpapi.dll, 0x73530000, 88 kB, Group Policy Client API
    iertutil.dll, 0x75c20000, 1.97 MB, Run time utility for Internet Explorer
    IGX.DLL, 0x1450000, 8.57 MB, Microsoft Igx
    imm32.dll, 0x74ff0000, 384 kB, Multi-User Windows IMM32 API Client DLL
    IPHLPAPI.DLL, 0x73910000, 112 kB, IP Helper API
    kernel32.dll, 0x76b40000, 1.06 MB, Windows NT BASE API Client DLL
    KernelBase.dll, 0x74db0000, 284 kB, Windows NT BASE API Client DLL
    KernelBase.dll.mui, 0xa720000, 768 kB, Windows NT BASE API Client DLL
    linkinfo.dll, 0x5c120000, 36 kB, Windows Volume Tracking
    locale.nls, 0x180000, 412 kB, 
    lpk.dll, 0x74c20000, 40 kB, Language Pack
    Microsoft.Office.Tools.Common.Implementation.ni.dll, 0xa010000, 864 kB, Microsoft.Office.Tools.Common.Implementation.dll
    Microsoft.Office.Tools.Common.ni.dll, 0x5780000, 352 kB, Microsoft.Office.Tools.Common.dll
    Microsoft.Office.Tools.Common.v4.0.Utilities.DLL, 0x4630000, 48 kB, Microsoft.Office.Tools.Common.v4.0.Utilities.dll
    Microsoft.Office.Tools.ni.dll, 0x679f0000, 36 kB, Microsoft.Office.Tools.dll
    Microsoft.Office.Tools.v4.0.Framework.ni.dll, 0x679d0000, 56 kB, Microsoft.Office.Tools.v4.0.Framework.dll
    Microsoft.VisualStudio.Tools.Applications.Hosting.ni.dll, 0x50e0000, 372 kB, Microsoft.VisualStudio.Tools.Applications.Hosting.dll
    Microsoft.VisualStudio.Tools.Applications.Runtime.ni.dll, 0x77330000, 140 kB, Microsoft.VisualStudio.Tools.Applications.Runtime.dll
    Microsoft.VisualStudio.Tools.Applications.ServerDocument.ni.dll, 0x77360000, 768 kB, Microsoft.VisualStudio.Tools.Applications.ServerDocument.dll
    Microsoft.VisualStudio.Tools.Office.Runtime.ni.dll, 0x77420000, 704 kB, Microsoft.VisualStudio.Tools.Office.Runtime.dll
    msasn1.dll, 0x77120000, 48 kB, ASN.1 Runtime APIs
    mscoree.dll, 0x71020000, 296 kB, Microsoft .NET Runtime Execution Engine
    mscoreei.dll, 0x70f40000, 492 kB, Microsoft .NET Runtime Execution Engine
    mscorlib.ni.dll, 0x8be0000, 16.18 MB, Microsoft Common Language Runtime Class Library
    msctf.dll, 0x756c0000, 816 kB, MSCTF Server DLL
    msi.dll, 0x65ea0000, 2.25 MB, Windows Installer
    msimg32.dll, 0x716f0000, 20 kB, GDIEXT Client DLL
    MSO.DLL, 0xa0f0000, 516 kB, Microsoft Office 2013 component
    MSO.DLL, 0x660e0000, 24.91 MB, Microsoft Office 2013 component
    MSOINTL.DLL, 0x61cc0000, 3.44 MB, Office International Resources
    MSORES.DLL, 0x5ced0000, 76.92 MB, Microsoft Office 2013 component
    MSPPT.OLB, 0x43c0000, 400 kB, Microsoft PowerPoint Object Library
    MSPTLS.DLL, 0xf170000, 1.09 MB, Microsoft Office 2013 component
    msvcp100.dll, 0x6a520000, 420 kB, Microsoft® C Runtime Library
    msvcr100.dll, 0x71380000, 764 kB, Microsoft® C Runtime Library
    msvcr110_clr0400.dll, 0x707c0000, 844 kB, Microsoft® C Runtime Library
    msvcrt.dll, 0x74d00000, 688 kB, Windows NT CRT DLL
    mswsock.dll, 0x74060000, 240 kB, Microsoft Windows Sockets 2.0 Service Provider
    msxml6.dll, 0x73b20000, 1.34 MB, MSXML 6.0 SP3
    msxml6r.dll, 0x4720000, 4 kB, XML Resources
    ncrypt.dll, 0x735b0000, 224 kB, Windows cryptographic library
    netprofm.dll, 0x5cbc0000, 360 kB, Network List Manager
    nlaapi.dll, 0x71bb0000, 64 kB, Network Location Awareness 2
    nlssorting.dll, 0x6acf0000, 72 kB, Microsoft Collation Support
    normaliz.dll, 0x75ab0000, 12 kB, Unicode Normalization DLL
    npmproxy.dll, 0x5cbb0000, 32 kB, Network List Manager Proxy
    nsi.dll, 0x75a50000, 24 kB, NSI User-mode interface DLL
    ntdll.dll, 0x76f70000, 1.66 MB, NT Layer DLL
    ntdll.dll, 0x77150000, 1.5 MB, NT Layer DLL
    ntmarta.dll, 0x71630000, 132 kB, Windows NT MARTA provider
    ntshrui.dll, 0x53030000, 448 kB, Shell extensions for sharing
    Nvd3d9wrap.dll, 0x71260000, 240 kB, NVIDIA Compatible NVIDIA d3d9wrap dll, Version 268.30 
    nvdxgiwrap.dll, 0x71220000, 236 kB, NVIDIA Compatible NVIDIA dxgiwrap dll, Version 268.30 
    nvinit.dll, 0x74190000, 204 kB, NVIDIA Compatible NVIDIA shim initialization dll, Version 268.30 
    OART.DLL, 0x6a0000, 13.66 MB, Microsoft OfficeArt
    OFFICE.ODF, 0x659a0000, 5 MB, Microsoft Office culture data dll
    ole32.dll, 0x74e90000, 1.36 MB, Microsoft OLE for Windows
    oleaut32.dll, 0x76c50000, 572 kB, 
    oledlg.dll, 0x774d0000, 112 kB, OLE User Interface Support
    OpenWaitPpt2013.VS2010.DLL, 0x4520000, 40 kB, OpenWaitPpt2013.VS2010
    OSPPC.DLL, 0x50090000, 180 kB, Office Software Licensing Client Dll
    POWERPNT.EXE, 0x3a0000, 1.77 MB, Microsoft PowerPoint
    PPCORE.DLL, 0xf5e0000, 9.92 MB, Microsoft PowerPoint
    PPINTL.DLL, 0x777c0000, 1.18 MB, Microsoft PowerPoint
    PPRESOURCES.DLL, 0x77680000, 1.23 MB, 
    profapi.dll, 0x75b10000, 44 kB, User Profile Basic API
    propsys.dll, 0x6ebe0000, 980 kB, Microsoft Property System
    rasadhlp.dll, 0x6a350000, 24 kB, Remote Access AutoDial Helper
    RICHED20.DLL, 0x774f0000, 1.55 MB, RichEdit Version 8.0
    rpcrt4.dll, 0x758d0000, 960 kB, Remote Procedure Call Runtime
    RpcRtRemote.dll, 0x6f210000, 56 kB, Remote RPC Extension
    rsaenh.dll, 0x73ff0000, 236 kB, Microsoft Enhanced Cryptographic Provider
    schannel.dll, 0x5c1b0000, 252 kB, TLS / SSL Security Provider
    sechost.dll, 0x75790000, 100 kB, Host for SCM/SDDL/LSA Lookup APIs
    secur32.dll, 0x6edc0000, 32 kB, Security Support Provider Interface
    segoeui.ttf, 0xb550000, 508 kB, 
    seguisb.ttf, 0xb980000, 400 kB, 
    SensApi.dll, 0x50b50000, 24 kB, SENS Connectivity API DLL
    setupapi.dll, 0x75340000, 1.61 MB, Windows Setup API
    shell32.dll, 0x75e60000, 12.29 MB, Windows Shell Common Dll
    shlwapi.dll, 0x74ca0000, 348 kB, Shell Light-weight Utility Library
    slc.dll, 0x55ee0000, 40 kB, Software Licensing Client Dll
    sortdefault.nlp, 0x9c10000, 2.82 MB, 
    SortDefault.nls, 0x40b0000, 2.81 MB, 
    srvcli.dll, 0x71950000, 100 kB, Server Service Client DLL
    sspicli.dll, 0x74b70000, 384 kB, Security Support Provider Interface
    StaticCache.dat, 0x11c40000, 9.19 MB, 
    stdole2.tlb, 0x46b0000, 16 kB, 
    sxs.dll, 0x71ae0000, 380 kB, Fusion 2.5
    System.Configuration.ni.dll, 0x71dd0000, 960 kB, System.Configuration.dll
    System.Core.ni.dll, 0x6b2a0000, 6.68 MB, .NET Framework
    System.Deployment.ni.dll, 0xa190000, 1.79 MB, System.Deployment.dll
    System.Drawing.ni.dll, 0x65480000, 1.58 MB, .NET Framework
    System.ni.dll, 0x6dd50000, 9.6 MB, .NET Framework
    System.Security.ni.dll, 0x643c0000, 728 kB, System.Security.dll
    System.Windows.Forms.ni.dll, 0x64830000, 12.31 MB, .NET Framework
    System.Xml.Linq.ni.dll, 0x8a50000, 400 kB, .NET Framework
    System.Xml.ni.dll, 0x6a590000, 7.32 MB, .NET Framework
    urlmon.dll, 0x75190000, 1.13 MB, OLE32 Extensions for Win32
    user32.dll, 0x75b20000, 1 MB, Multi-User Windows USER API Client DLL
    userenv.dll, 0x76d20000, 92 kB, Userenv
    usp10.dll, 0x75050000, 628 kB, Uniscribe Unicode script processor
    uxtheme.dll, 0x71670000, 512 kB, Microsoft UxTheme Library
    VBE6EXT.OLB, 0x46c0000, 40 kB, Microsoft Visual Basic for Applications Extensibility
    version.dll, 0x746e0000, 36 kB, Version Checking and File Installation Libraries
    vstoee.dll, 0x50070000, 120 kB, Visual Studio Tools for Office Execution Engine
    VSTOLoader.dll, 0x50020000, 268 kB, Visual Studio Tools for Office Loader
    webio.dll, 0x6ee00000, 316 kB, Web Transfer Protocols API
    webservices.dll, 0x77950000, 776 kB, Windows Web Services Runtime
    WindowsCodecs.dll, 0x6a1d0000, 1.19 MB, Microsoft Windows Codecs Library
    winhttp.dll, 0x6ee50000, 352 kB, Windows HTTP Services
    wininet.dll, 0x75500000, 1.71 MB, Internet Extensions for Win32
    winmm.dll, 0x6a420000, 200 kB, MCI API DLL
    winnsi.dll, 0x73900000, 28 kB, Network Store Information RPC interface
    winsta.dll, 0x72f10000, 164 kB, Winstation Library
    wintrust.dll, 0x75ac0000, 184 kB, Microsoft Trust Verification APIs
    Wldap32.dll, 0x75a60000, 276 kB, Win32 LDAP API DLL
    wow64.dll, 0x746a0000, 252 kB, Win32 Emulation on NT64
    wow64cpu.dll, 0x74630000, 32 kB, AMD64 Wow64 CPU 
    wow64win.dll, 0x74640000, 368 kB, Wow64 Console and Win32 API Logging
    ws2_32.dll, 0x74be0000, 212 kB, Windows Socket 2.0 32-Bit DLL
    wship6.dll, 0x73930000, 24 kB, Winsock2 Helper DLL (TL/IPv6)
    WSHTCPIP.DLL, 0x74050000, 20 kB, Winsock2 Helper DLL (TL/IPv4)
    wtsapi32.dll, 0x71b70000, 52 kB, Windows Remote Desktop Session Host Server SDK APIs
    xmllite.dll, 0x6edd0000, 188 kB, Microsoft XmlLite Library
    {AFBF9F1A-8EE8-4C77-AF34-C647E37CA0D9}.1.ver0x00000000000001f9.db, 0x4890000, 172 kB, 
    ~FontCache-FontFace.dat, 0xc2f0000, 16 MB, 
    ~FontCache-S-1-5-21-1392800327-2415074910-3460020496-1000.dat, 0xd2f0000, 8 MB, 
    ~FontCache-System.dat, 0xb4a0000, 692 kB, 


    Friday, May 2, 2014 11:13 AM

Answers

  • Hi dzmitry

    I could reproduce the issue as you mentioned.

    You could use the code below to open a PowerPoint file through PowerPoint PIA (Add a new reference named "Office.dll" to use MsoTriState):

    Application ppt = new Application();
    ppt.Visible = MsoTriState.msoTrue;
    Console.WriteLine(ppt.Version);
    ppt.Presentations.Open(System.IO.Path.Combine(Environment.CurrentDirectory, "PPT_simple_2013.pptx"));
    Console.ReadKey();
    ppt.Quit();

    In this case, I only found one PowerPoint application.

    In addition, the figure may give you help:


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, May 5, 2014 6:48 AM
    Moderator

All replies

  • I found hack for case via PInvoke native wait method.

       [DllImport("kernel32.dll", SetLastError = true)]
            internal static extern UInt32 WaitForSingleObject(SafeWaitHandle hHandle, UInt32 dwMilliseconds);

    Also if there is some .NET waits inside what we use upon start (e.g. Thread.Join, wait for Process or WCF) then will need to rework all usages if handles are parts of public APIs.

    So simple case if fixed by hack, real case is much harder.

    Sunday, May 4, 2014 1:22 PM
  • Hi dzmitry

    I could reproduce the issue as you mentioned.

    You could use the code below to open a PowerPoint file through PowerPoint PIA (Add a new reference named "Office.dll" to use MsoTriState):

    Application ppt = new Application();
    ppt.Visible = MsoTriState.msoTrue;
    Console.WriteLine(ppt.Version);
    ppt.Presentations.Open(System.IO.Path.Combine(Environment.CurrentDirectory, "PPT_simple_2013.pptx"));
    Console.ReadKey();
    ppt.Quit();

    In this case, I only found one PowerPoint application.

    In addition, the figure may give you help:


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, May 5, 2014 6:48 AM
    Moderator