一些來源我已經檢查: http://www.experts-exchange.com/Programming/Languages/.NET/Visual_Basic.NET/Q_23359339.html
http://mygreenpaste.blogspot.com/2006/03/net-framework-20-configuration-tool.html
http://support.microsoft.com/kb/186063VB6自動化錯誤調用
我忙於開發.NET模塊將鉤到我們現有的VB6代碼中。我創建從中推出新的代碼,包括帶有按鈕的形式的測試VB6項目,並在按鈕的單擊事件是
Dim launcher As New VB6InteropLaunchPad.launcher
launcher.FormTypeEnum = FormTypeEnum_MySpecificForm
launcher.launchAppropriateForm
它是成功的,我第一次單擊按鈕。但是,如果我再次點擊該按鈕時,我得到以下錯誤:
Run-time error '-2146233079 (80131509)': Automation Error
後續調用.NET代碼失敗,相同的錯誤消息,除非我關閉並重新啓動IDE。如果我將VB6項目編譯爲EXE,則會發生同樣的情況。我必須關閉EXE並再次運行它才能訪問.NET代碼。
我試過的建議上http://support.microsoft.com/kb/186063,也做了以下內容: 顯式的選項
' http://support.microsoft.com/kb/186063
Const FORMAT_MESSAGE_FROM_SYSTEM = &H1000
Private Declare Function FormatMessage Lib "kernel32" Alias _
"FormatMessageA" (ByVal dwFlags As Long, lpSource As Long, _
ByVal dwMessageId As Long, ByVal dwLanguageId As Long, _
ByVal lpBuffer As String, ByVal nSize As Long, Arguments As Any) _
As Long
Private Function MessageText(lCode As Long) As String
Dim sRtrnCode As String
Dim lRet As Long
sRtrnCode = Space$(256)
lRet = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, 0&, lCode, 0&, _
sRtrnCode, 256&, 0&)
If lRet > 0 Then
MessageText = Left(sRtrnCode, lRet)
Else
MessageText = "Error not found."
End If
End Function
On Error GoTo errHandler
Dim launcher As New VB6InteropLaunchPad.launcher
launcher.FormTypeEnum = FormTypeEnum_MySpecificForm
launcher.launchAppropriateForm
Exit Sub
errHandler:
MsgBox MessageText(Err.Number)
MsgBox Err
,但沒有發現錯誤。
有關如何解決此問題的任何想法?我試圖set launcher = Nothing
但它沒有幫助。
謝謝你們。
感謝普拉特先生!請在頁面底部查看我的完整評論。 – AndrewJacksonZA 2009-09-29 14:26:51