0

我在 VS 2010 中使用项目模板构建了一个简单的 InteropForms 类。它构建成功并在系统中注册了库。我可以在 VB6 中看到并引用它,但是我在 VS2010 中添加到类中的公共方法或属性都不可见。

我究竟做错了什么?

Imports Microsoft.InteropFormTools

<InteropForm()> _
Public Class frmWebBrowserPreview
    Private Sub frmWebBrowserPreview_KeyUp(sender As System.Object, e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyUp
        If e.KeyCode = Windows.Forms.Keys.Escape Then Hide()
    End Sub

    Private Sub frmWebBrowserPreview_MouseUp(sender As System.Object, e As System.Windows.Forms.MouseEventArgs) Handles MyBase.MouseUp
        Hide()
    End Sub

    Private Sub wbrPreview_DocumentCompleted(sender As Object, e As System.Windows.Forms.WebBrowserDocumentCompletedEventArgs) Handles wbrPreview.DocumentCompleted
        wbrPreview.Visible = True
    End Sub

    ''' <summary>
    ''' Navigate to the specified URL
    ''' </summary>
    ''' <param name="strURL">The URL string</param>
    Public Function Navigate(strURL As String) As Boolean
        wbrPreview.Navigate(strURL)
    End Function
End Class
4

1 回答 1

0

模板来自工具包:VB6 InteropForm Library

VS2012 不支持它(还...)... VS2012 工具包

我想到了。您必须向相关方法添加一个 InteropFormMethod 属性,然后重新构建包装器。

    ''' <summary>
''' Navigate to the specified URL
''' </summary>
''' <param name="strURL">The URL string</param>
<InteropFormMethod()> _
Public Function Navigate(strURL As String) As Boolean
    wbrPreview.Navigate(strURL)
End Function
于 2013-10-14T18:04:22.797 回答