G
GS
in a class WebCtlExt inherited from system.windows.form.webbrowser, I have
Private cookie As AxHost.ConnectionPointCookie
Private wevents As WebBrowserExtendedEvents
.......
Protected Overrides Sub CreateSink()
'MAKE SURE TO CALL THE BASE or the normal events won't fire
MyBase.CreateSink()
wevents = New WebBrowserExtendedEvents(Me)
cookie = New AxHost.ConnectionPointCookie(Me.ActiveXInstance,
wevents, GetType(DWebBrowserEvents2)) ' <<< oops error
End Sub
....
end class
<ComImport(), _
Guid("34A715A0-6587-11D0-924A-0020AFC7AC4D"), _
InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIDispatch), _
TypeLibType(TypeLibTypeFlags.FHidden)> _
Public Interface DWebBrowserEvents2
<DispId(250)> _
Sub BeforeNavigate2(<[In](), MarshalAs(UnmanagedType.IDispatch)> ByVal
pDisp As Object, _
<InAttribute(), MarshalAs(UnmanagedType.BStr)> ByRef URL As String, _
<InAttribute()> ByRef flags As Object, _
<InAttribute(), MarshalAs(UnmanagedType.BStr)> ByRef targetFrameName As
String, _
<InAttribute()> ByRef postdata As Object, _
<InAttribute(), MarshalAs(UnmanagedType.BStr)> ByRef headers As String,
_
<InAttribute(), OutAttribute()> ByRef cancel As Boolean)
'Note: Postdata is a SafeArray but for some reason, if I do a proper
declaration, the event will not be raised:
'<[In](), MarshalAs(UnmanagedType.SafeArray,
safearraysubtype:=VarEnum.VT_UI1)> ByRef postdata() As Byte, _
<DispId(273)> _
Sub NewWindow3(<InAttribute(), MarshalAs(UnmanagedType.IDispatch)> ByVal
pDisp As Object, _
<InAttribute(), OutAttribute()> ByRef cancel As Boolean, _
<InAttribute()> ByRef Flags As Object, _
<InAttribute(), MarshalAs(UnmanagedType.BStr)> ByRef UrlContext As
String, _
<InAttribute(), MarshalAs(UnmanagedType.BStr)> ByRef Url As String)
End Interface 'DWebBrowserEvents2
' ---------ERROR msg ::::::::::::::
System.InvalidCastException was unhandled by user code
Message="Source object does not expose IConnectionPointContainer."
Source="System.Windows.Forms"
StackTrace:
at System.Windows.Forms.AxHost.ConnectionPointCookie..ctor(Object
source, Object sink, Type eventInterface, Boolean throwException)
at System.Windows.Forms.AxHost.ConnectionPointCookie..ctor(Object
source, Object sink, Type eventInterface)
at myapp.WebCtlExt.CreateSink() in c:\myApp\webCtlExt.vb:line 104
at myapp.WebCtlExt.CreateSink_() in c:\myApp\webCtlExt.vb:line 96
at myapp.webCtl.webCtl_Load(Object sender, EventArgs e) in
c:\myApp\webCtl.vb:line 13
at System.EventHandler.Invoke(Object sender, EventArgs e)
at System.Windows.Forms.UserControl.OnLoad(EventArgs e)
at System.Windows.Forms.UserControl.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.SetVisibleCore(Boolean value)
what should my code be?
I am using vistual studio 2005 vb express dotnet2.
thank you
Private cookie As AxHost.ConnectionPointCookie
Private wevents As WebBrowserExtendedEvents
.......
Protected Overrides Sub CreateSink()
'MAKE SURE TO CALL THE BASE or the normal events won't fire
MyBase.CreateSink()
wevents = New WebBrowserExtendedEvents(Me)
cookie = New AxHost.ConnectionPointCookie(Me.ActiveXInstance,
wevents, GetType(DWebBrowserEvents2)) ' <<< oops error
End Sub
....
end class
<ComImport(), _
Guid("34A715A0-6587-11D0-924A-0020AFC7AC4D"), _
InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIDispatch), _
TypeLibType(TypeLibTypeFlags.FHidden)> _
Public Interface DWebBrowserEvents2
<DispId(250)> _
Sub BeforeNavigate2(<[In](), MarshalAs(UnmanagedType.IDispatch)> ByVal
pDisp As Object, _
<InAttribute(), MarshalAs(UnmanagedType.BStr)> ByRef URL As String, _
<InAttribute()> ByRef flags As Object, _
<InAttribute(), MarshalAs(UnmanagedType.BStr)> ByRef targetFrameName As
String, _
<InAttribute()> ByRef postdata As Object, _
<InAttribute(), MarshalAs(UnmanagedType.BStr)> ByRef headers As String,
_
<InAttribute(), OutAttribute()> ByRef cancel As Boolean)
'Note: Postdata is a SafeArray but for some reason, if I do a proper
declaration, the event will not be raised:
'<[In](), MarshalAs(UnmanagedType.SafeArray,
safearraysubtype:=VarEnum.VT_UI1)> ByRef postdata() As Byte, _
<DispId(273)> _
Sub NewWindow3(<InAttribute(), MarshalAs(UnmanagedType.IDispatch)> ByVal
pDisp As Object, _
<InAttribute(), OutAttribute()> ByRef cancel As Boolean, _
<InAttribute()> ByRef Flags As Object, _
<InAttribute(), MarshalAs(UnmanagedType.BStr)> ByRef UrlContext As
String, _
<InAttribute(), MarshalAs(UnmanagedType.BStr)> ByRef Url As String)
End Interface 'DWebBrowserEvents2
' ---------ERROR msg ::::::::::::::
System.InvalidCastException was unhandled by user code
Message="Source object does not expose IConnectionPointContainer."
Source="System.Windows.Forms"
StackTrace:
at System.Windows.Forms.AxHost.ConnectionPointCookie..ctor(Object
source, Object sink, Type eventInterface, Boolean throwException)
at System.Windows.Forms.AxHost.ConnectionPointCookie..ctor(Object
source, Object sink, Type eventInterface)
at myapp.WebCtlExt.CreateSink() in c:\myApp\webCtlExt.vb:line 104
at myapp.WebCtlExt.CreateSink_() in c:\myApp\webCtlExt.vb:line 96
at myapp.webCtl.webCtl_Load(Object sender, EventArgs e) in
c:\myApp\webCtl.vb:line 13
at System.EventHandler.Invoke(Object sender, EventArgs e)
at System.Windows.Forms.UserControl.OnLoad(EventArgs e)
at System.Windows.Forms.UserControl.OnCreateControl()
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl(Boolean fIgnoreVisible)
at System.Windows.Forms.Control.CreateControl()
at System.Windows.Forms.Control.SetVisibleCore(Boolean value)
what should my code be?
I am using vistual studio 2005 vb express dotnet2.
thank you