Getting Error when opening visio document through Visio SDK 2010 from sharepoint

Started by zeeshan3, January 19, 2012, 09:56:29 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

zeeshan3

I am getting an exception while opening an existing visio document through the Visio SDK 2010 from a sharepoint2010 application page.

The visio document is already placed on the hard disk of the sharepoint server whose path is "D:\abc\BasicFlow.vdw".

I am using the "Microsoft.Office.Interop.Visio" dll of the Visio SDK 2010 to open the document.I did the same thing in a Console application i.e. open an existing visio document and it was working fine but when I wrote the same into the sharepoint2010 page, it started to crash.

Below is the code that I am using for opening the document.

Kindly let me know if anybody has done this before because I have searched for it almost everywhere but found no solution.I am trying to automate visio programmatically but I am getting a COM Exception when trying to open the document.

Thanks.



Microsoft.Office.Interop.Visio.Application application = new Microsoft.Office.Interop.Visio.Application();
application.Visible = false;
Microsoft.Office.Interop.Visio.Documents documents = application.Documents;
Microsoft.Office.Interop.Visio.Document doc = application.Documents.Open(@"D:\abc\BasicFlow.vdw");


aledlund

and when you wrap it in a try...catch to get the extended error information, what is it saying the problem is?
al

Paul Herber

Electronic and Electrical engineering, business and software stencils for Visio -

https://www.paulherber.co.uk/

zeeshan3

Hi,

I am using Visio 2010 along with Sharepoint 2010.

I am using the Microsoft.Office.Interop.Visio.dll for opening the existing document of the Visio SDK 2010.

I applied try catch and getting a COM exception saying that "An Error has occured" and doesn't give any other details.

Also there is one Documents.CheckOut() method in the SDK for sharepoint which checksout the file you are trying to open but when I call it passing the path of the document library where the file exixts for e.g "http://sharepoint02:500/sites/My workspace/MyVisioFile.vdw", it gives a File not found Exception.

But I am calling Documents.Open method of the SDK passing it the physical path of the file on the server's harddrive and not the path of the document library in sharepoint.

Kindly let me know if any other information is needed.

Jumpy

Quote from: zeeshan3 on January 20, 2012, 06:13:10 AM
But I am calling Documents.Open method of the SDK passing it the physical path of the file on the server's harddrive and not the path of the document library in sharepoint.

You know that the Document.Open part is responsible for the error? Did you check out another normal visio file .vsd? A file on the local harddrive?

Only fishing in the dark: Maybe mapping doesn't work and you have to use the UNC-Path?

Jumpy

zeeshan3


Yes I have tried many other files on the server's harddrive and they all are failing when Document.Open method is called from sharepoint but they are successfully opened when I am trying to call them from a Console application.

I dont think that path is the issue.It is the sharepoint environment that is not allowing the SDK to open the document.

Paul Herber

Can you open Visio then do File -> Open and browse to the file and open it manually?
Can you open the file from Windows Explorer?
Electronic and Electrical engineering, business and software stencils for Visio -

https://www.paulherber.co.uk/

zeeshan3


Paul Herber

use the .OpenEx method instead of .Open and set the Read/Write status.
Electronic and Electrical engineering, business and software stencils for Visio -

https://www.paulherber.co.uk/

zeeshan3

I have tried the OpenEx method but it is also giving the same exception.

Paul Herber

Electronic and Electrical engineering, business and software stencils for Visio -

https://www.paulherber.co.uk/

zeeshan3


Hi,

I tried the following versions.

doc = application.Documents.OpenEx(@"D:\abc\BasicFlow.vdw", (short)Microsoft.Office.Interop.Visio.VisOpenSaveArgs.visOpenRW | Microsoft.Office.Interop.Visio.VisOpenSaveArgs.visOpenCopy);

doc = application.Documents.OpenEx(@"D:\abc\BasicFlow.vdw", (short)Microsoft.Office.Interop.Visio.VisOpenSaveArgs.visOpenRW);

doc = application.Documents.OpenEx(@"D:\abc\BasicFlow.vdw", (short)Microsoft.Office.Interop.Visio.VisOpenSaveArgs.visOpenRO);

doc = application.Documents.OpenEx(@"D:\abc\BasicFlow.vdw", (short)Microsoft.Office.Interop.Visio.VisOpenSaveArgs.visOpenRO);

Paul Herber

Electronic and Electrical engineering, business and software stencils for Visio -

https://www.paulherber.co.uk/

aledlund


If the document is saved as a visio drawing (vsd), can you open it (goes to file type)?

Since it works locally and fails on the network, can you open the document with visio natively from sharepoint (goes to security, firewalls and permissions )?

have you attempted using the sharepoint sample code from the SDK (checkin/checkout), which would be the normal way of accessing the file?

al

zeeshan3


I need to display the drawing in a sharepoint web page thatswhy it must be .vdw file type and vsd will not work.

I am not trying to open it from a network.I am running the code from the sharepoint server itself  and not from a remote machine so that the file could be treated as a local file.So, I don't think that firewalls could be the problem in this case.

Yes I have tried using the CheckOut method of the SDK and I am passing it the following parameter.

"http://sharepoint02:500/sites/My_workspace/MyVisioFile.vdw".

but it gives me an exception of "Invalid parameter".The Visio file exists in the document library of sharepoint and I verified it by copying the above path into the browser and it displays the properly which means the file exists over there.