0

由于无法解释的错误,我最初发布了这个问题,询问有关日志记录的问题。我现在找到了日志信息,并在错误方面取得了一些进展。我正在重写问题以更具体地针对错误。


我正在尝试在 AWS“Elastic Beanstalk”上运行 .NET (4.0) 工作进程(从 SQS 队列读取并将结果写入 RDS 数据库)。要部署这样的工作线程,必须将其构建为 Windows 服务(请参阅上一个问题:使用 Elastic Beanstalk 部署 .NET 工作线程应用程序)。我的 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"));
    }

产生预期的诊断(两封电子邮件和一个 EventLog 条目)和否FileNotFoundException(电子邮件方法中的异常只是一个虚拟对象 - 我的电子邮件方法旨在自动将异常通过电子邮件发送到我的邮箱)。

这证实了缺少程序集/包的假设 - 我的注释代码中的某些内容正在使用缺少的包。我怎样才能确定什么?如何确定存在哪些程序集和包?

我的应用程序确实包含很多 DLL,但看起来这些 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 工作者应用程序类似的东西)

4

1 回答 1

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()
于 2013-10-25T21:02:12.440 回答