Visio Guy

Visio Discussions => Visio 2010 Issues => Topic started by: zeeshan3 on January 19, 2012, 09:56:29 AM

Title: Getting Error when opening visio document through Visio SDK 2010 from sharepoint
Post by: zeeshan3 on January 19, 2012, 09:56:29 AM
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");

Title: Re: Getting Error when opening visio document through Visio SDK 2010 from sharepoint
Post by: aledlund on January 19, 2012, 12:59:43 PM
and when you wrap it in a try...catch to get the extended error information, what is it saying the problem is?
al
Title: Re: Getting Error when opening visio document through Visio SDK 2010 from sharepoint
Post by: Paul Herber on January 19, 2012, 01:01:40 PM
and which version of Visio do you have?
Title: Re: Getting Error when opening visio document through Visio SDK 2010 from sharepoint
Post by: zeeshan3 on January 20, 2012, 06:13:10 AM
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.
Title: Re: Getting Error when opening visio document through Visio SDK 2010 from sharepoint
Post by: Jumpy on January 20, 2012, 07:12:34 AM
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
Title: Re: Getting Error when opening visio document through Visio SDK 2010 from sharepoint
Post by: zeeshan3 on January 20, 2012, 07:18:58 AM

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.
Title: Re: Getting Error when opening visio document through Visio SDK 2010 from sharepoint
Post by: Paul Herber on January 20, 2012, 07:31:48 AM
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?
Title: Re: Getting Error when opening visio document through Visio SDK 2010 from sharepoint
Post by: zeeshan3 on January 20, 2012, 07:57:40 AM

yes I can open the file both manually and from the Windows Explorer.
Title: Re: Getting Error when opening visio document through Visio SDK 2010 from sharepoint
Post by: Paul Herber on January 20, 2012, 08:04:17 AM
use the .OpenEx method instead of .Open and set the Read/Write status.
Title: Re: Getting Error when opening visio document through Visio SDK 2010 from sharepoint
Post by: zeeshan3 on January 20, 2012, 10:24:16 AM
I have tried the OpenEx method but it is also giving the same exception.
Title: Re: Getting Error when opening visio document through Visio SDK 2010 from sharepoint
Post by: Paul Herber on January 20, 2012, 10:27:51 AM
What parameters do you pass to it?
Title: Re: Getting Error when opening visio document through Visio SDK 2010 from sharepoint
Post by: zeeshan3 on January 20, 2012, 11:08:19 AM

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);
Title: Re: Getting Error when opening visio document through Visio SDK 2010 from sharepoint
Post by: Paul Herber on January 20, 2012, 11:21:42 AM
ok, well, sorry, I'm all out of ideas for the time being.
Title: Re: Getting Error when opening visio document through Visio SDK 2010 from sharepoint
Post by: aledlund on January 20, 2012, 01:13:40 PM

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
Title: Re: Getting Error when opening visio document through Visio SDK 2010 from sharepoint
Post by: zeeshan3 on January 21, 2012, 08:02:20 AM

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.
Title: Re: Getting Error when opening visio document through Visio SDK 2010 from sharepoint
Post by: aledlund on January 21, 2012, 12:58:26 PM
"I am not trying to open it from a network", is a common misconception since you are using networking (even if it is on the same machine).

"So, I don't think that firewalls could be the problem in this case.", firewalls are probably not the issue in your configuration - but that does not rule out permissions. I'd start by investigating the directory properties => security and see who is authorized.

If you cannot open the file with Visio directly, then attempting to open it via code is probably a waste of time - since both Visio and your application are going to run into the same problem.

Since you can open the file when it is truly local (and not owned by sharepoint), it is probably not a Visio problem. It is how you have Sharepoint set up, or are attempting to access it.

al
Title: Re: Getting Error when opening visio document through Visio SDK 2010 from sharepoint
Post by: zeeshan3 on January 21, 2012, 06:27:40 PM

I am able to open the directly through Visio and also through Sharepoint by going to the document library.

I also created a simple asp.net web application and tried to access the same Visio drawing in it through the Visio Interop API and it was successfully opened.

So, If the file is opening from everywhere except sharepoint, it may be a permissions issue with sharepoint but I have checked all the permissions given to sharepoint and the document library and the folder in which the file resides.
Title: Re: Getting Error when opening visio document through Visio SDK 2010 from sharepoint
Post by: labiche on January 21, 2013, 07:22:44 PM
I am having a very similar problem but it is when I try to OpenEx the "Basic_U.vss" stencil.

The code has been working quite well in a console application but now I'm porting it into a Sharepoint Webpart.

I've been advised to map a folder for TEMPLATES into my visual studio solution, but haven't got the magic right yet.
Anyone know if this thread was solved?

thanks,

Maurice


Code is:

Visio.Document visioStencilDocument = oVisio.Documents.OpenEx("Basic_U.vss",
                    (short)Microsoft.Office.Interop.Visio.VisOpenSaveArgs.visOpenHidden);



Exception Text is:  (with partial stack trace)
System.Runtime.InteropServices.COMException was unhandled by user code
  Message=The server threw an exception. (Exception from HRESULT: 0x80010105 (RPC_E_SERVERFAULT))
  Source=Microsoft.Office.Interop.Visio
  ErrorCode=-2147417851
  StackTrace:
       at Microsoft.Office.Interop.Visio.DocumentsClass.OpenEx(String FileName, Int16 Flags)