views:

43

answers:

1

Hi guys,

I have a database that is accessed by two applications. The first is an ASP.NET MVC application which just reads data out of the database. The second is a C# Console application which reads and writes to the database.

The problem I'm experiencing is that when the console application performs a mass update of up to several hundred rows, the MVC application will crash and burn. If I purge the entire database and refill it, the MVC application comes back to life, but anytime the console application needs to perform an update the MVC app will crash.

What I assume is happening is that the DataContext in the MVC application sees that the data has changed and doesn't know what to do. Or at least that's what I think is happening because the exception being thrown, System.Web.HttpUnhandledException, is really vague and is being caught by the OnException Controller override.

I have tried several fixes, but none of which did anything:

  1. Restarting IIS or the entire server does not help.
  2. Overriding the OnActionExecuting in the Controller and telling it to create a new DataContext does not work.
  3. Overriding the OnActionExecuting in the Controller and telling it to refresh the DataContext does not work. (Although I'm not 100% sure this failed because I did this:)

    DataContext.Refresh(System.Data.Linq.RefreshMode.OverwriteCurrentValues, this);

The compiler let it go through so I assumed it understood what I was trying to do...

  1. (4) Wrapping each ActionResult with a using statement and creating a new DataContext doesn't work.

I would appreciate any suggestions anyone might have on how I should fix this.

Thanks in advance!

A: 

Check the inner exception. If the inner exception is null, make sure you are doing a "throw" not a "throw ex" so that the stack trace doesn't get reset.

thekaido