2012-11-24 42 views
0

我正在使用Backgroundworker(在vb.net中)。 我在Windows 8 Pro(64位)下工作,項目工作正常......但如果我在Windows 7(64位)的計算機上傳輸可執行文件,會發生一件奇怪的事情! BackgroundWorker的DoWork不起作用,它直接跳到RunWorkerCompleted。 我不明白爲什麼。 我使用Visual Studio 2012 Express Edition進行編譯。 你有想法解決這個問題嗎? 謝謝。在另一臺計算機上跳過Backgroundworker的DoWork

這是一些代碼:

Private Sub bgw_extract_DoWork(sender As Object, e As System.ComponentModel.DoWorkEventArgs) Handles bgw_extract.DoWork 
     MsgBox("test dowork") 'this appear 
     extract_cycle() 'this isn't executed 
     MsgBox("end dowork") 'this isn't executed 
End Sub 


Private Sub extract_cycle() 
'nothing is executed here 
     MsgBox("test2") 'not executed 
     Try 
      'my code.... 
     Catch ex As Exception 
      MessageBox.Show(ex.ToString(), "Extract Error", MessageBoxButtons.OK, MessageBoxIcon.Error) 
     End Try 
End Sub 


Private Sub bgw_extract_RunWorkerCompleted(sender As Object, e As System.ComponentModel.RunWorkerCompletedEventArgs) Handles 
bgw_extract.RunWorkerCompleted 
     MsgBox("RunWorkCompleted") 'this is executed in every case 
End Sub 
+0

您是否嘗試用最小的例子縮小問題範圍? – JohnB

+0

[未處理的異常未在C#中捕獲]的可能的重複(http://stackoverflow.com/questions/10463408/unhandled-exception-not-caught-in-c-sharp) –

+0

可以顯示一些代碼,它有點困難猜猜你在做什麼? – Patrick

回答

0

可能你的extract_cycle方法引用了一個組件,該組件不存在在目標機器上;並且因此拋出異常時(因此在執行MsgBox("test2")之前)。

如果你catch unhandled exceptions(或者甚至查看事件日誌),你應該能夠看到發生了什麼。

+0

謝謝!使用Try Catch作爲例外,我發現它「無法加載文件或程序集」Ionic.Zip「」這是一個.dll,我怎麼能包括它? – Kaos

+0

@Kaos,可以將其複製到與其他程序集相同的目錄中,或者運行一個安裝程序將其安裝到GAC中。 – Joe

相關問題