Microsoft.Office.Interop.Visio.Application.Documents.open throws null reference pointer exception RRS feed

  • Question

  • Sorry for the double post (those of you who follow other forums) but I was unsure which forum to post this question...

    I am attempting to open a Visio 2013 document in C#. The source code is pretty simple and I've done this successfully with other office docs (like Powerpoint) My IDE is Visual Studio 2017. The reference I am using in my project is Microsoft.Office.Interop.Visio version (file: 14.0.4756.1000)

    The problem is that when the open is called: vsdApp.Documents.Open it farts out an exception:

    An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred A null reference pointer was passed to the stub. (Exception from HRESULT: 0x800706F4)

    I'm really at a loss to explain this one as the code is stupid simple:

    static void Main(string[] args)
        string vis = "F:\\scratch\\visio.vsd";
        if (!System.IO.File.Exists(vis))
                throw new Exception("FAIL: Input file does not exist: " + vis);
        Microsoft.Office.Interop.Visio.Application vsdApp = new Microsoft.Office.Interop.Visio.Application();
        vsdApp.Visible = false;
        Microsoft.Office.Interop.Visio.Document vsdDoc = vsdApp.Documents.Open( vis );

    Sunday, September 27, 2020 2:45 PM

All replies

  • Hi Mark.MSDN,

    Thank you for posting here.

    Make sure that you have installed Visio Primary Interop Assembly, then try to reinstall the 'Microsoft.Office.Interop.Visio', or use another computer to do the test again.

    Best Regards,

    Xingyu Zhao

    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Monday, September 28, 2020 8:23 AM