I have a project with one Web role and one Worker role. Both my web and worker roles work as intended whenever I locally test it. (Note, although the local version uses the Azure Compute Emulator, the Service Bus queue and Message queue use the live cloud version.) However, the Cloud Service worker role has a tendency to crash during certain operations. It causes the instance to "Recycle" and the message gets stuck in the Azure Service Bus queue. It isn't until I locally run the cloud service that it successfully processes the message and then removes it from the queue. Even when the role works, Azure often tells me on the dashboard that the worker role is running "unhealthy."
At one point, the Azure portal printed this error:
Unhandled Exception: System.Reflection.ReflectionTypeLoadException
I've added exception handling in my project for this and tried again after deploying the update to the cloud, but the same thing keeps happening. When I added the exception handling to my project, I had to add the System.Reflection library to my worker role, but this confused me even more. I don't understand why I'm receiving an error for a call to a library that I did not even originally use in my project.
Anyone have any ideas on what this problem could be?
Update:
I did some manual debugging, and noticed that the exception is being called in the Run() of the Worker Role. The line of code causing the problem involves making a call to the database using Entity Framework. The specific line is:
Image imageEntity = db.Images.Find(ImgViewFromQueue.Id);
I'm wondering if the issue has to do with Entity Framework not being enabled or configured properly on the Azure server.