0

我最初發布的這個問題是關於由於無法解釋的錯誤導致的日誌記錄。我現在已經找到了日誌信息,並在錯誤中取得了一些進展。我正在重寫這個問題,以更具體的錯誤。如何確定在Elastic Beanstalk實例上運行Windows服務時缺少哪些包?


我試圖運行.NET(4.0)工作進程(從SQS隊列中讀取,並將結果寫入到數據庫RDS)在AWS上「彈性魔豆」。要部署這樣的工作人員,必須將其構建爲Windows服務(請參閱上一個問題:Deploying a .NET worker app with Elastic Beanstalk)。我的Windows服務啓動一個包裝我的主要處理循環的新線程。這在我的Win7 PC上運行良好。

部署到Elastic Beanstalk(Win Server 2013)似乎工作正常,但只要服務遇到我的線程方法,我就得到FileNotFoundException。這令人費解,因爲一旦它碰到我的MainProcessingMethod()並且在可能產生任何診斷之前似乎發生異常。經過一番網絡搜索之後,我發現在Windows服務中丟失的程序包&可能會生成FileNotFoundException,並且通常沒有關於缺少程序集的信息。

我相信我已經證實了這一點。下面的處理方法只包括診斷:

public void MainProcessingMethod() 
    { 
     EmailSender.SendExceptionEmail("Main started", null, new Exception("main started")); 
     EventLog.WriteEntry("WebPlagiarismService", "MainProcessingMethod running", EventLogEntryType.Information); 
     EmailSender.SendExceptionEmail("Main finishing", null, new Exception("main finished")); 
    } 

產生預期的診斷(兩封電子郵件和事件日誌條目),並沒有FileNotFoundException(以電子郵件方式異常僅僅是一種對象 - 我的電子郵件方法的目的是虛自動將例外發送到我的郵箱)。

這證實了缺少的程序集/軟件包假設 - 我評論的代碼中的某些內容正在使用缺少的軟件包。我怎樣才能確定什麼? 如何確定組件&存在?

我的應用程序確實包含了很多DLL,但它看起來像正在被發現 - 上面的電子郵件方法是在其中一個DLL中定義的。

調試模式不會添加任何更多信息。這裏的例外/堆棧:(應用程序更名爲MyTestService)

Analysis symbol: 
Rechecking for solution: 0 
Report Id: 51a8153f-3d92-11e3-9426-22000aeb1e73 
Report Status: 4 
Hashed bucket: 
2013-10-25T16:27:20.000Z Error 100:Application Crashing Events Application Error - Faulting application name: MyTestService.exe, version: 1.0.0.0, time stamp: 0x526a97a6 
Faulting module name: KERNELBASE.dll, version: 6.2.9200.16451, time stamp: 0x50988aa6 
Exception code: 0xe0434352 
Fault offset: 0x000000000003811c 
Faulting process id: 0x76c 
Faulting application start time: 0x01ced19f12e04665 
Faulting application path: c:\Data\TestApp\MyTestService.exe 
Faulting module path: C:\Windows\system32\KERNELBASE.dll 
Report Id: 51a8153f-3d92-11e3-9426-22000aeb1e73 
Faulting package full name: 
Faulting package-relative application ID: 
2013-10-25T16:27:19.000Z Error 0:(0) .NET Runtime - Application: MyTestService.exe 
Framework Version: v4.0.30319 
Description: The process was terminated due to an unhandled exception. 
Exception Info: System.IO.FileNotFoundException 
Stack: 
    at MyTestService.MyTestService.MainProcessingMethod() 
    at 
System.Threading.ExecutionContext.RunInternal(System.Threading.ExecutionContext, 
System.Threading.ContextCallback, System.Object, Boolean) 
    at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, 
System.Threading.ContextCallback, System.Object, Boolean) 
    at System.Threading.ExecutionContext.Run(System.Threading.ExecutionContext, 
System.Threading.ContextCallback, System.Object) 
    at System.Threading.ThreadHelper.ThreadStart() 

我也看到錯誤「部署包不包含iisApp」,這是有道理的,因爲這僅僅是一個服務,而不是一個真正的Web應用程序(我看到類似於我的Python工作應用的東西)

回答

0

訣竅是添加一個包裝方法,並用try ... catch包含主處理方法。那麼這在抓住主要處理方法開始組裝負載,例如:

 try 
     { 
      MainProcessingMethod_internal(); 
     } 
     catch (Exception e) 
     { 
      EmailSender.SendExceptionEmail("Main_intern", null, e); 
     } 

請注意,我用我現有的異常電子郵件方法。

而結果呢?這是缺失的所有東西的AWSSDK!

Exception: Could not load file or assembly 'AWSSDK, Version=1.5.36.0, Culture=neutral, PublicKeyToken=9f476d3089b52be3' or one of its dependencies. The system cannot find the file specified. 
    at WebPlagiarismService.WebPlagiarismService.MainProcessingMethod_intern() 
    at WebPlagiarismService.WebPlagiarismService.MainProcessingMethod() 
Source: WebPlagiarismService 
Target: Void MainProcessingMethod_internal() 
相關問題