none
在做vb6.0調用.net編寫的Com時 ,注冊時發生錯誤,在線等,謝謝!! RRS feed

  • 问题

  • 我在註冊程序集時出現以下的錯誤.

    RegAsm : error RA0000 : 無法從組件 'FDLQueryNotification, Version=1.0.0.0, Cultu
    re=neutral, PublicKeyToken=5956621ecd912476' 載入型別 'iWarning'

     

    我的程序如下: 以前程序註冊可以通過,加以下紅色代碼段後,注冊錯誤,望指教!!!!!!

    Public Interface iNotification
        Property ADO_ConnString() As String
        Property QueryString() As String
        Function BeginTrace() As String
        Function Begindo() As String
        Sub initclass(Optional ByVal a As String = "", Optional ByVal b As String = "")
        Event EventQuery()
        Sub TraceEvent()
        Sub sqlDependency_OnChange(ByVal sender As Object, ByVal e As System.Data.SqlClient.SqlNotificationEventArgs)
        Function enddo() As String
    End Interface

     

    <System.Runtime.InteropServices.InterfaceType(System.Runtime.InteropServices.ComInterfaceType.InterfaceIsIDispatch)> _
    Public Interface iWarning
        Sub onupdatedata()
    End Interface

    Public Delegate Sub UpdateDataDelegate()


    <System.Runtime.InteropServices.ComSourceInterfaces("iWarning"), System.Runtime.InteropServices.ClassInterface(System.Runtime.InteropServices.ClassInterfaceType.None)> _
    Public Class QueryNotification
        Implements iNotification
        Private mstrConnString As String
        Private mstrQueryString As String
        Private conn As System.Data.SqlClient.SqlConnection = Nothing
        Private command As System.Data.SqlClient.SqlCommand = Nothing
        Public Event EventQuery() Implements iNotification.EventQuery
        Public Event onupdatedata As UpdateDataDelegate

    #Region "initclass"
        <System.Runtime.InteropServices.ComVisible(True)> _
        Public Sub initclass(Optional ByVal ConnString As String = "", Optional ByVal QueryString As String = "") _
            Implements iNotification.initclass


            If ConnString.Trim.Length > 0 Then
                mstrConnString = ConnString
            Else
                mstrConnString = "Data Source=192.9.199.1;Initial Catalog=tempdb;Integrated Security=True"
            End If

            If QueryString.Trim.Length > 0 Then
                mstrQueryString = QueryString
            Else
                mstrQueryString = "select id,name from dbo.test where id<>4 order by id desc "
            End If


        End Sub
    #End Region

    #Region "屬性 ADO_ConnString"
        <System.Runtime.InteropServices.ComVisible(True)> _
        Public Property ADO_ConnString() As String _
                Implements iNotification.ADO_ConnString
            Get
                ADO_ConnString = mstrConnString
            End Get
            Set(ByVal value As String)
                mstrConnString = value
            End Set
        End Property
    #End Region

    #Region "屬性 QueryString"
        <System.Runtime.InteropServices.ComVisible(True)> _
        Public Property QueryString() As String _
            Implements iNotification.QueryString
            Get
                QueryString = mstrQueryString
            End Get
            Set(ByVal value As String)
                mstrQueryString = value
            End Set
        End Property
    #End Region

    #Region "開始追縱 BeginTrace"

        <System.Runtime.InteropServices.ComVisible(True)> _
        Public Function BeginTrace() As String _
            Implements iNotification.BeginTrace

            Try
                System.Data.SqlClient.SqlDependency.Start(mstrConnString) '启动

                If mstrConnString.Trim.Length = 0 Then
                    BeginTrace = "請先使用ADO_ConnString屬性設置連接字符串."
                End If
                conn = New System.Data.SqlClient.SqlConnection(mstrConnString)
                command = conn.CreateCommand()
                If mstrConnString.Trim.Length = 0 Then
                    BeginTrace = "請先使用QueryString屬性設置需要查詢通知的語句."
                End If
                command.CommandText = mstrQueryString
                Call TraceEvent()

            Catch ex As Exception
                BeginTrace = ex.Message
            End Try

            BeginTrace = ""
        End Function

    #End Region

    #Region "設置通知事件"
        <System.Runtime.InteropServices.ComVisible(True)> _
        Public Sub TraceEvent() _
            Implements iNotification.TraceEvent
            command.Notification = Nothing '清除
            Dim dependency As New System.Data.SqlClient.SqlDependency(command) '设置通知
            AddHandler dependency.OnChange, AddressOf sqlDependency_OnChange '通知事件

            '通知事件
            Using adapter As New System.Data.SqlClient.SqlDataAdapter(command)
                '查询数据
                Dim ds As System.Data.DataSet = New DataSet()
                adapter.Fill(ds, 0, 3, "test")
            End Using
        End Sub
    #End Region

    #Region "通知事件 sqlDependency_OnChange"
        <System.Runtime.InteropServices.ComVisible(True)> _
        Public Sub sqlDependency_OnChange(ByVal sender As Object, ByVal e As System.Data.SqlClient.SqlNotificationEventArgs) _
            Implements iNotification.sqlDependency_OnChange
            RaiseEvent onupdatedata()
            Dim dependency As System.Data.SqlClient.SqlDependency = DirectCast(sender, System.Data.SqlClient.SqlDependency)
            RemoveHandler dependency.OnChange, AddressOf sqlDependency_OnChange
            '通知之后,当前dependency失效,需要重新TraceEvent并且设置通知
            Call TraceEvent()
        End Sub
    #End Region

        <System.Runtime.InteropServices.ComVisible(True)> _
            Public Function Begindo() As String _
                Implements iNotification.Begindo
            Begindo = "qwqw"
        End Function

        <System.Runtime.InteropServices.ComVisible(True)> _
         Public Function Enddo() As String _
             Implements iNotification.enddo
            Enddo = "qwqw"
        End Function


    End Class

    2009年1月16日 6:06

答案