2

I've build an own application based on Visio 2010 which implements the visio drawing frontend by using AxMicrosoft.Office.Interop.VisOcx. The application works fine over many years with Visio 2010. Now i want to use my application with an installed Visio 2016. It works almost everything except saving VSD-Files to network drives. But saving VSD-Files on the local drive works fine. If i want to save the VSD-File on a network drive it causes on an error in
Microsoft.Office.Interop.Visio.DocumentClass.SaveAs(String FileName)

This is my environment:
Windows 10, Visual Studio 2013, .NET 4.5, C#, Viso Standard 2016.

These Visio libraries are in use:
AxInterop.Microsoft.Office.Interop.VisOcx
Microsoft Visio 16.0 Drawing Control Type Library
Version: 1.2.0.0

Microsoft.Office.Interop.Visio
Microsoft Visio 16.0 Type Library
Version: 4.16.0.0

Microsoft.Office.Interop.VisOcx
Microsoft Visio 16.0 Drawing Control Type Library
Version: 1.4.0.0

To save a VSD-File in my application i use the Method AxDrawingControl.Document.SaveAs()

but whenever I save on a network drive it occurs the unspecified error:

Error while saving 'configuration'
(Note: The document may be open in Visio at the same time.)
Exception occurred.
at Microsoft.Office.Interop.Visio.DocumentClass.SaveAs(String FileName)

The strange thing is, that the document is not opened twice as mentioned at the error message. I've already tried several network drives e.g. shared Folder on other Windows-Client and Windows-Server. I also tried a shared folder on Linux-Server with Samba-Service. It doesn't make any difference either i mount a drive letter or use the fully network path. Saving to network drives does not work. But saving on local drive works fine.

You can reproduce this error independently of my application in a few steps with Visual Studio and an installed Visio 2013, 2016 or 2019.

  • Create a new Windows Forms Application in Visual Studio
  • Add the COM Controlelement ‘Microsoft Visio 16.0 Drawing Control’ by using the toolbox
  • At the end of the method InitializeComponent() you have to add the following lines:
this.axDrawingControl1.Src = "C:\\temp\\OrigDoc.vsd";
var targetDocument = this.axDrawingControl1.Document;
targetDocument.SaveAs("\\\\10.1.5.45\\visio-projects\\SavedDoc.vsd");

Bevor executing you have to add a Visio VSD-File named OrigDoc.vsd to c:/temp and change the path to your network drive in the last line of code. As a network drive, you can take any shared drive, e.g. a shared folder on a Windows client. The error will be occurs after executing this application. If you change the file extension in the last line from SavedDoc.vsd to SavedDoc.vsdx the error doesn’t occurs. This behavior looks like a bug in the Microsoft Visio interface Microsoft.Office.Interop.Visio or Microsoft.Office.Interop.VisOcx.

Does anyone have any idea how to solve the problemn that Visio VSD-Files can't be saved on a network drive?

0 Answers0