Metodo WebBrowser.DetachSink
Assembly: System.Windows.Forms (in system.windows.forms.dll)
Questo metodo è utile per coloro che hanno familiarità con lo sviluppo OLE tramite il controllo ActiveX non gestito WebBrowser e che desiderano estendere la funzionalità del controllo Windows Form WebBrowser, che costituisce un wrapper gestito per il controllo ActiveX. È possibile utilizzare questa extensibility per implementare gli eventi del controllo ActiveX che non sono forniti dal controllo del wrapper.
Nell'esempio di codice riportato di seguito viene illustrato l'utilizzo di questo metodo in una classe derivata da WebBrowser che fornisce un supplemento agli eventi WebBrowser standard con l'evento NavigateError dell'interfaccia OLE DWebBrowserEvents2.
Per l'esempio di codice completo, vedere CreateSink.
AxHost.ConnectionPointCookie cookie; WebBrowser2EventHelper helper; [PermissionSetAttribute(SecurityAction.LinkDemand, Name="FullTrust")] protected override void CreateSink() { base.CreateSink(); // Create an instance of the client that will handle the event // and associate it with the underlying ActiveX control. helper = new WebBrowser2EventHelper(this); cookie = new AxHost.ConnectionPointCookie( this.ActiveXInstance, helper, typeof(DWebBrowserEvents2)); } [PermissionSetAttribute(SecurityAction.LinkDemand, Name="FullTrust")] protected override void DetachSink() { // Disconnect the client that handles the event // from the underlying ActiveX control. if (cookie != null) { cookie.Disconnect(); cookie = null; } base.DetachSink(); }
- SecurityPermission per consentire l'utilizzo del controllo ai chiamanti immediati. Valore richiesta: LinkDemand; Set di autorizzazioni denominati: FullTrust.
Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile per Pocket PC, Windows Mobile per Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
Microsoft .NET Framework 3.0 è supportato in Windows Vista, Microsoft Windows XP SP2 e Windows Server 2003 SP1.