Question

I originally posted this question asking about logging due to an unexplained error. I have now found the log info and have made a small amount of progress with the error. I am re-writing the question to be more specific to the error.


I am trying to run a .NET (4.0) worker process (reads from an SQS queue and writes the results to an RDS database) on AWS "Elastic Beanstalk". To deploy a worker like this, it has to be built as a Windows service (see previous question: Deploying a .NET worker app with Elastic Beanstalk ). My Windows service starts a new thread which wraps my main processing loop. This works fine on my Win7 PC.

Deployment to Elastic Beanstalk (Win Server 2013) appears to be working fine, but as soon as the service hits my thread method, I get a FileNotFoundException. This was puzzling because the exception appeared to occur as soon as it hit my MainProcessingMethod() and before any diagnostics could be produced. After a bit of web searching, I found that missing packages & assemblies in Windows services can produce a FileNotFoundException, and often without any information as to what the missing assembly is.

I believe I have confirmed this. The following processing method that only consists of diagnostics:

    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"));
    }

Produces the expected diagnostics (two emails and an EventLog entry) and no FileNotFoundException (the exception in the email method is just an dummy object- my email method is intended to automatically email exceptions to my mailbox).

This confirms the missing assembly/package hypothesis - something in my commented code is using a package that is missing. How can I determine what? How can I determine what assemblies&packages are present?

My application does include quite a few DLLs but it looks like these are being found - the above email method is defined in one of the DLLs.

Debug mode does not add any further information. Here's the exception / stack: (app renamed to 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()

I am also seeing errors 'Deployment package did not contain an iisApp' which makes sense as this is just a service and not a true web app (I see something similar with my Python worker app)

Was it helpful?

Solution

The trick is to add a wrapper method, and enclose the main processing method with a try...catch. Then this catches the assembly load at the beginning of the main processing method, e.g.:

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

Note that I am using my existing exception email method.

And the result? It is the AWSSDK of all things that is missing!

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()
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top