public override void DoCommand(object sender, EventArgs args) { var webSite = GetSelectedAzureWebSite(); if (webSite == null) { throw new NotSupportedException(); } Uri debugUri; if (Uri.TryCreate(webSite.Uri, "/ptvsd", out debugUri)) { // Open the site's ptvsd page if it exists var req = WebRequest.CreateHttp(debugUri.AbsoluteUri); req.Method = "HEAD"; req.Accept = "text/html"; var dlgFactory = (IVsThreadedWaitDialogFactory)_serviceProvider.GetService(typeof(SVsThreadedWaitDialogFactory)); IVsThreadedWaitDialog2 dlg = null; if (dlgFactory != null && ErrorHandler.Succeeded(dlgFactory.CreateInstance(out dlg))) { if (ErrorHandler.Failed(dlg.StartWaitDialog( Strings.ProductTitle, Strings.DebugAttachGettingSiteInformation, null, null, null, 1, false, true ))) { dlg = null; } } try { req.GetResponse().Close(); } catch (WebException) { debugUri = null; } finally { if (dlg != null) { int dummy; dlg.EndWaitDialog(out dummy); } } } if (debugUri != null) { CommonPackage.OpenWebBrowser(_serviceProvider, debugUri.AbsoluteUri); } else { CommonPackage.OpenWebBrowser(_serviceProvider, "http://go.microsoft.com/fwlink/?LinkID=624026"); } }
public override void DoCommand(object sender, EventArgs args) { if (_useVSBrowser) { CommonPackage.OpenVsWebBrowser(_serviceProvider, _url); } else { CommonPackage.OpenWebBrowser(_url); } }
private Task StartBrowser(string url, Func <bool> shortCircuitPredicate) { Uri uri; if (!string.IsNullOrWhiteSpace(url) && Uri.TryCreate(url, UriKind.RelativeOrAbsolute, out uri)) { var tcs = new TaskCompletionSource <object>(); OnPortOpenedHandler.CreateHandler( uri.Port, shortCircuitPredicate: shortCircuitPredicate, action: () => { try { var web = _serviceProvider.GetService(typeof(SVsWebBrowsingService)) as IVsWebBrowsingService; if (web == null) { CommonPackage.OpenWebBrowser(url); return; } ErrorHandler.ThrowOnFailure( web.CreateExternalWebBrowser( (uint)__VSCREATEWEBBROWSER.VSCWB_ForceNew, VSPREVIEWRESOLUTION.PR_Default, url ) ); } catch (Exception ex) when(!ex.IsCriticalException()) { tcs.SetException(ex); } finally { tcs.TrySetResult(null); } } ); return(tcs.Task); } return(Task.FromResult <object>(null)); }