2013-03-27 25 views
1

爲什麼我在用下面的代碼開始我的.NET應用程序(QCSearch.exe)得到Error 6: Overflow獲取溢出錯誤在從VBA運行.NET應用程序使用的WshShell

Private Sub StartQCSearch() 
    Dim wsh As WshShell 
    Dim waitOnReturn As Boolean: waitOnReturn = True 
    Dim windowStyle As Integer: windowStyle = 1 
    Dim errorCode As Integer 
    Dim pth As String 

    Set wsh = New WshShell 
    pth = ThisWorkbook.Path & "\QCSearch.exe" 
    // Following line is marked, when debugging error 6: 
    errorCode = wsh.Run(pth, windowStyle, waitOnReturn) 
    If errorCode <> 0 Then 
     MsgBox "QCSearch.exe exited with error code " & errorCode & "." 
    End If 
End Sub 

的.NET應用程序(寫在c#)有一個主窗體,打開一個對話框。 當我確認這個對話框時,發生錯誤6並且.NET應用程序立即關閉。

看起來對話框正在返回一些不能由errorCode分配的退出代碼。 但正如我所說,我檢查了我的.NET應用程序的退出代碼,然而,他們通常不應該通過關閉任何對話框來返回,而是通過關閉主窗體?!

此外,調試錯誤後,該errorCode變量仍被指定爲0

感謝提前任何幫助。

更新

當.NET應用程序從Windows CMD開始,它也確認對話框後壞。現在,我真的很困惑。有誰知道爲什麼內部對話框關閉整個應用程序?

回答

0

好吧,永遠不會忘記要做到這一點,如果用相對路徑在.NET應用程序的工作:

wsh.CurrentDirectory = ThisWorkbook.Path 
+0

你應該紀念這個作爲一個問題的答案,如果這是你的原意。將自己的答案標記爲自己的問題是可以的。 – Kyle 2013-03-27 14:35:59

+0

好的,但我只允許在兩天內做到這一點。 – fachexot 2013-03-27 14:45:33

相關問題