VSTO Add-Ins get disabled when opening a file from Sharepoint or SkyDrive using Windows Explorer: Invalid URI
-
22 กุมภาพันธ์ 2555 7:52
When a VSTO Add-In is installed and a Word document is opened from Windows Explorer, Word disables the Add-In and shows an error:
"System.UriFormatException: Invalid URI: The hostname could not be parsed"This only happens when a document is opened from a Sharepoint/SkyDrive folder (when WebDAV is used).
Steps to reproduce:
1. Install any VSTO Add-In using setup.exe
2. Navigate to a Sharepoint 2010 Document List
3. Choose 'Actions' and then 'Open with Windows Explorer'
4. Windows Explorer is opened
5. Open a .docx in Windows Explorer with double-click
6. The VSTO Add-In fails with an error and gets disabled, see exception text below.I use Visual Studio 2010 with VSTO 4.0 and MS Word 2010.
All Windows Updates are applied.This is a common scenario that many of our customers use, so this is a major issue.
Is there a hotfix or workaround available for this?
Findings:
If a Sharepoint file is opened using Windows Explorer, the current working directory is something like: \\www.website.com@SSL\DavWWWRoot\path
(One can see this with Process Explorer from sysinternals).
I did a small test and found that .NET indead reports Environment.CurrentDirectory as \\www.website.com@SSL\DavWWWRoot\path
In the beginning of the VSTO Add-In loading process, there is a new Uri(Environment.CurrentDirectory) which fails with the error listed below.
.NET can't parse the working directory as an URL and throws the error.For testing purposes; Skydrive also has WebDAV access using \\d.docs.live.net@SSL\DavWWWRoot\<cid> where <cid> is the hex number that is in your querystring when you are logged on in skydrive
https://skydrive.live.com/?cid=<cid>&....
Error details reported by Word:Invalid URI: The hostname could not be parsed.
************** Exception Text **************
System.UriFormatException: Invalid URI: The hostname could not be parsed.
at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind)
at System.Uri..ctor(String uriString)
at Microsoft.VisualStudio.Tools.Office.Runtime.OfficeAddInDeploymentManager.OnAddInInstalling(AddInInstallingArgs args, Boolean& cancel)
at Microsoft.VisualStudio.Tools.Applications.Deployment.ClickOnceAddInDeploymentManager.RaiseOnAddInInstallingEvent(IClickOnceAddInInstaller addInInstaller, Uri deploymentManifestUri, AddInInstallationStatus addinSolutionState, String productName, Boolean alreadyInstalled)
at Microsoft.VisualStudio.Tools.Applications.Deployment.ClickOnceAddInDeploymentManager.InstallAddIn()
************** Loaded Assemblies **************
mscorlib
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.530 (RTMLDR.030319-5300)
CodeBase: file:///C:/Windows/Microsoft.NET/Framework/v4.0.30319/mscorlib.dll
----------------------------------------
Microsoft.VisualStudio.Tools.Office.Runtime
Assembly Version: 10.0.0.0
Win32 Version: 10.0.31119.0
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/Microsoft.VisualStudio.Tools.Office.Runtime/v4.0_10.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualStudio.Tools.Office.Runtime.dll
----------------------------------------
System.Core
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.450 built by: RTMLDR
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Core/v4.0_4.0.0.0__b77a5c561934e089/System.Core.dll
----------------------------------------
System
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.530 built by: RTMLDR
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System/v4.0_4.0.0.0__b77a5c561934e089/System.dll
----------------------------------------
Microsoft.VisualStudio.Tools.Applications.Hosting
Assembly Version: 10.0.0.0
Win32 Version: 10.0.31119.0
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/Microsoft.VisualStudio.Tools.Applications.Hosting/v4.0_10.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualStudio.Tools.Applications.Hosting.dll
----------------------------------------
Microsoft.VisualStudio.Tools.Applications.ServerDocument
Assembly Version: 10.0.0.0
Win32 Version: 10.0.31119.0
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/Microsoft.VisualStudio.Tools.Applications.ServerDocument/v4.0_10.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualStudio.Tools.Applications.ServerDocument.dll
----------------------------------------
Microsoft.VisualStudio.Tools.Applications.Runtime
Assembly Version: 10.0.0.0
Win32 Version: 10.0.31119.0
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/Microsoft.VisualStudio.Tools.Applications.Runtime/v4.0_10.0.0.0__b03f5f7f11d50a3a/Microsoft.VisualStudio.Tools.Applications.Runtime.dll
----------------------------------------
System.Windows.Forms
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.454 built by: RTMLDR
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Windows.Forms/v4.0_4.0.0.0__b77a5c561934e089/System.Windows.Forms.dll
----------------------------------------
System.Drawing
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 built by: RTMRel
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Drawing/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Drawing.dll
----------------------------------------
System.Deployment
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.1 (RTMRel.030319-0100)
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Deployment/v4.0_4.0.0.0__b03f5f7f11d50a3a/System.Deployment.dll
----------------------------------------
System.Xml
Assembly Version: 4.0.0.0
Win32 Version: 4.0.30319.450 built by: RTMLDR
CodeBase: file:///C:/Windows/Microsoft.Net/assembly/GAC_MSIL/System.Xml/v4.0_4.0.0.0__b77a5c561934e089/System.Xml.dll
----------------------------------------
ตอบทั้งหมด
-
24 กุมภาพันธ์ 2555 7:06ผู้ดูแล
Hi,
I tried to run the scenario as above, but could not reproduce the problem. I tried to deploy Word addin in both Clickonce and Windows Installer, open document from Sharepoint library works, open document located in Skydrive also works. Note that the Sharepoint server doesn't enable SSL, do you have SSL enable in Sharepoint?
I noticed that in your Process Explorer finding, working directory contains sign '@' , not sure why it is there. But I'm pretty sure this caused the exception.
From callstack, it looks the exception pops up when install the addin, could you check where you published the addin to?
Best Regards,
Forrest Guo | MSDN Community Support | Feedback to us
-
24 กุมภาพันธ์ 2555 15:43
If the '@' sign is the problem in the URL, it is a problem of WebDAV over a HTTPS connection then, not over HTTP.
The '@SSL' supposedly indicates that an SSL connection should be used.
We have multiple Sharepoint sites where we use SSL because they are available on the internet.Could you try it from Skydrive?
Skydrive also uses SSL.
When logging into https://www.skydrive.com and navigating to a directory, there is a 'cid' in the querystring.
With "\\d.docs.live.net@SSL\<cid>" in Windows explorer, it is possible to open documents from SkyDrive from Windows explorer.
This is also used by Word when you use File -> Save & Send -> Save to webThe installation location of the VSTO (we use location like http://computer/test.vsto) does not matter, the error is because of the current directory.
Unfortunately, the VSTO add-ins get disabled after installation too, even if the update frequency is set to 'Never' -
24 กุมภาพันธ์ 2555 15:58ผู้ดูแล
Hi,
I have tried Windows Live Skydrive, which url is https://skydrive.live.com/ , different from what you mentioned. The Word addin loads well in this situation. When you mentioned, you check the working directory by Process Explorer and get \\d.docs.live.net@SSL\DavWWWRoot\<cid> Would you let me know how you get it. I ask because I don't see Working Directory property in Word process in Process Explorer.
Best Regards,
Forrest Guo | MSDN Community Support | Feedback to us
-
27 กุมภาพันธ์ 2555 3:15ผู้ดูแล
Hi,
Is there any progress made over there? Let me know if I can help please.
Regards,
Forrest Guo | MSDN Community Support | Feedback to us
-
2 มีนาคม 2555 10:08
Yes, I'm sorry, it is skydrive.live.com, but that is only to find out the CID to use.
Please log on toskydrive, navigate to a folder (e.g. 'Documents'), the browser shows an url like:
https://skydrive.live.com/#cid=8859DD4133671A0E&id=8859DD4133671A0E%21129The code 8859DD4133671A0E is the CID here, this code is different for every user (this one is fake, I made up one).
The steps I use are:
1. Make sure all Word processes are shut down, no winword.exe in process explorer
2. Open Windows explorer (not the browser)
3. Enter \\d.docs.live.net@SSL\DavWWWRoot\8859DD4133671A0E where 8859DD4133671A0E is the CID retrieved from skydrive website
4. Enter credentials
5. Navigate to a subfolder with a .docx
6. Open the document by double-clicking
7. Word opens with a working directory \\d.docs.live.net@SSL\DavWWWRoot\8859DD4133671A0E\Subfolder
See Process Explorer to check
8. VSTO add-ins fail -
7 มีนาคม 2555 7:17
Hi,
currently i have build an application level add-in for word. i'm using some custom user controls inside the add in.
the add-in was running smoothly except when i open the document template from sharepoint. if i open it from sharepoint, the add-in was loaded because i can see my custom ribbon but not my other custom controls(i'm using somekind of an action pane on the left side on the document layout). all of my code validation for the add-in is not triggered
does anybody know what went wrong?
really need help on this issue.
Thanks.
-Willy-
-Regards- Willy Noviandy
-
7 มีนาคม 2555 8:02Add some logging to your add-in or attach debugger and see what is executed.
-
7 มีนาคม 2555 8:17
Hi Damian,
i already did that, i also add some messagebox on the code to see whether the code is being triggered or not. but the result is still nothing. i use addinspy to check the add in, the add in was successfuly loaded but not my validation code behind the add in.
i got lost there.
any other idea?
Thanks.
-Regards- Willy Noviandy
-
7 มีนาคม 2555 14:11ผู้ดูแล
Hi,
Thank you sending us the detail reproduce steps. I did reproduced this problem at first, but later on, I found the clue.
Results depends on the way we deploy Word addin:
- if it's deployed to normal folder, like c:\users\xx\documents\project\, then I see this error;
- but I run the addin successfully if it is deployed by Windows installer, deployed to folder like: c:\program files\Microsoft\WordAddin\, then opening document on https folder will load the addin without any problem.
So, I agree item 1 is a defect that we can improve; and item2 could be a way that could work out the scenario.
I have created a connect issue report as below, people can follow up the issue:
Best Regards,
Forrest Guo | MSDN Community Support | Feedback to us
- เสนอเป็นคำตอบโดย Forrest GuoMicrosoft, Moderator 8 มีนาคม 2555 6:05
- ทำเครื่องหมายเป็นคำตอบโดย Forrest GuoMicrosoft, Moderator 13 มีนาคม 2555 3:45
-
13 มีนาคม 2555 3:44ผู้ดูแล
Got confirmation from VSTO engineering team: VSTO addin doesn't load via UNC path, that SSL is enabled. The workaround include:
1. Open the document using a regular https URL rather than using UNC (\\) notation
2. Copy the document locally manually, then open from that locationBest Regards,
Forrest Guo | MSDN Community Support | Feedback to us
- ทำเครื่องหมายเป็นคำตอบโดย Forrest GuoMicrosoft, Moderator 13 มีนาคม 2555 3:45