none
Problems automating Visio in Windows Server 2012 RRS feed

  • Question

  • Hi,

    We currently encountered a problem automating Visio (2010) under Windows Server 2012. Our job is simply open a Visio diagram, make some small changes (Shape Texts), and then export it to SVG and HTML.

    It has been working fine in Windows Server 2003, 2008 and 2008 R2. But in Windows Server 2012, we got this error:

    System.Runtime.InteropServices.COMException (0x86DB03E7): An exception occurred.   at Microsoft.Office.Interop.Visio.PageClass.Export(String FileName)

    Some notes:

    1. We run our job as Windows Service under a specific service account (also added as Local Administrator on the server)

    2. We can't find any information about the error:  0x86DB03E7. It is a mystery.

    3. When trying to find solutions on two Windows Server 2012 instances running in Azure, we managed to get it through by wrapping automation code inside an STA Thread. And after that, the error has just gone, even when we switched back to the original automation code.

    4. When trying to test same work-around (using STA Thread) on an Windows Server 2012 instance hosted in a Hyper-V. It didn't help. So we replaced the Window Service with a Console Application (to run in interactive mode), then automation code worked. However, as long as we switch back to use Windows Service, same error happens.

    Does anyone know what the error 0x86DB03E7 is about? What change in Windows Server 2012 could be the cause of this? Or how should we modify our code in order to get it work under Windows Server 2012?

    P.S.: We are aware of Server-side Automation warning from MS, so please discard any general advise about that. Our product's main features depend a lot on Visio (and other Office Applications) which is by far there is no such a diagramming tool supporting interoperabilities as we need like Visio.

    Thanks in advance.

    Best Regards,

    Duy 


    Friday, June 6, 2014 9:21 AM

Answers

  • Hello Duy,

    > We are aware of Server-side Automation warning from MS, so please discard any general advise about that. Our product's main features depend a lot on Visio (and other Office Applications) which is by far there is no such a diagramming tool supporting interoperabilities as we need like Visio. 

     It look like you already know the answer to your questions. You are lucky if you didn't see any exceptions in previous versions of the server OS. The only possible solution is to use any third-party products that don't require Visio installed on the PC. For example, take a look at Aspose.Diagram for .NET .

    For everybody who meet such issue first time, the Considerations for server-side Automation of Office article states the following:

    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.

    BTW What value do you pass to the Export method? Note, the C: drive requires admin privileges.

    Friday, June 6, 2014 11:46 AM

All replies

  • Hello Duy,

    > We are aware of Server-side Automation warning from MS, so please discard any general advise about that. Our product's main features depend a lot on Visio (and other Office Applications) which is by far there is no such a diagramming tool supporting interoperabilities as we need like Visio. 

     It look like you already know the answer to your questions. You are lucky if you didn't see any exceptions in previous versions of the server OS. The only possible solution is to use any third-party products that don't require Visio installed on the PC. For example, take a look at Aspose.Diagram for .NET .

    For everybody who meet such issue first time, the Considerations for server-side Automation of Office article states the following:

    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.

    BTW What value do you pass to the Export method? Note, the C: drive requires admin privileges.

    Friday, June 6, 2014 11:46 AM
  • "Microsoft.Office.Interop.Visio.PageClass.Export(String FileName"

    I'd start by checking for logged security errors, ensuring that the target filename/location allows for 'writes' from your application. Did the file ever get written? Can your application execute on a Win 8.1 system (since that OS shares it's core with srv2012)?

    al


    Al Edlund Visio MVP


    • Edited by Al Edlund Friday, June 6, 2014 12:30 PM
    Friday, June 6, 2014 12:28 PM
  • Hi Eugene,

    We passed the full-path of output SVG file (same location as original VSD file). And our services do run under Local Administrator accounts = have admin privileges.

    We are looking into Apose.Diagram too, however since we do quite number of modification to Shapes in original Visio (VSD) file, so it will take quite a while to make sure that Apose.Diagram has enough features we need as well as rewriting our services for using Apose.Diagram. On the other hand, as you might know, Visio has oftenly changed its Object Model each time new version is released, hence compatibility is always one of our major issue.

    Saturday, June 7, 2014 3:28 AM
  • Hi Al,

    - I don't think it is security error. We first save original VSD file to that location, then open it, make some modifications, then export to both SVG & HTML to the same location. The strange thing is that it can be exported to HTML without problem, but not to SVG.

    - Yes we did test our services on Windows 8.1, and so far no problem happens.

    - We did use Process Monitor tool to check if there could be any file write issue, but it didn't help

    Saturday, June 7, 2014 3:34 AM
  • Duy,

    Only one solution is possible - use any third party components for creating/modifying diagrams on the server. It doesn't matter what Visio proposes with each new version due to the fact that the scenario you are trying to implement at the moment is not supported.


    Saturday, June 7, 2014 12:59 PM
  • Did you find a solution?  I am in the same boat - just looking for a way to convert a Visio .svgz to a .png file.  I have been able to uncompress with GZIP and then use the svgengine to convert to .PNG but that is not clean and does not do a good job of converting.

    This worked fine in the past when we used automation from vfp but now I am considering a com wrapper to be able to get it to work.


    . · * ´ ¨ ) .· ` T C H ( . . · *

    Tuesday, July 14, 2015 8:46 PM
  • Correction, the image renders with issues using SVGEngine so not a good solution.

    . · * ´ ¨ ) .· ` T C H ( . . · *


    • Edited by tcCoder Thursday, July 23, 2015 4:56 PM
    Friday, July 17, 2015 1:24 PM
  • Hi tcCoder,

    You can use Aspose.Pdf API in two steps. In first step convert SVG to PDF and later convert resultant PDF to PNG. Please check following help topics for details/code snippet. 

    1) Convert SVG to PDF document

    URL: http://www.aspose.com/docs/display/pdfnet/Convert+SVG+file+to+PDF+format

    2) Convert PDF pages to PNG

    URL: http://www.aspose.com/docs/display/pdfnet/Convert+all+PDF+pages+to+PNG+Images

    Please also refer to the following download page.

    Download Aspose APIs: http://www.aspose.com/community/files/default.aspx

    I work with Aspose as Developer Evangelist.

    Wednesday, November 18, 2015 10:17 AM
  • It is now working using the NetOffice Visio API.

    . · * ´ ¨ ) .· ` T C H ( . . · *

    • Proposed as answer by tcCoder Monday, December 28, 2015 4:10 PM
    Monday, December 28, 2015 4:10 PM