我一直在将VB.NET应用程序转换为C#。在大多数情况下,这是一个平稳的操作。
在VB.NET中,我可以使用以下代码将NewWindow3句柄添加到WebBrowser控件中;
Public Sub New()
InitializeComponent()
WebBrowserCOM.Navigate("about:blank")
Dim svd As SHDocVw.WebBrowser = DirectCast(WebBrowserCOM.ActiveXInstance, SHDocVw.WebBrowser)
AddHandler svd.NewWindow3, AddressOf NewWindow3
End Sub
Public Sub NewWindow3(ByRef pDisp As Object, ByRef cancel As Boolean, ByVal flags As Integer, ByVal URLContext As String, ByVal URL As String)
...
End Sub
我将其翻译为;
public frmAutoStateCertInput() {
InitializeComponent();
WebBrowserCOM.Navigate("about:blank");
SHDocVw.WebBrowser svd = (SHDocVw.WebBrowser)WebBrowserCOM.ActiveXInstance;
svd.NewWindow3 += NewWindow3();
}
public void NewWindow3(out object ppDisp, out bool Cancel, uint dwFlags, string bstrUrlContext, string bstrUrl) {
...
}
但是当我将其转换为C#时,会出现错误;
Error CS0123 No overload for 'NewWindow3' matches delegate 'DWebBrowserEvents2_NewWindow3EventHandler'
我应该怎么做才能解决此问题?
编辑:错误出现在“ svd.NewWindow3 + = NewWindow3();”上线。