Hi,

I try to fix issues with deadlocks. And I see that you have some trick in Global.asax.cs for reprocessing of error (TryToReprocessRequest). Possibly it could help me but unfortunately it doesn't work.

Error is raised during processing of request. HttpRuntime.ProcessRequest(wr); "Operation is not valid due to the current state of the object."

Environment: WindowsServer 2003, IIS6

Do you know the reason?

asked Oct 22 '10 at 06:31

Denis's gravatar image

Denis
7225

edited Oct 22 '10 at 11:13

Alex%20Yakunin's gravatar image

Alex Yakunin
29714412

Could you publish a full stack trace?

(Oct 22 '10 at 08:16) Alex Yakunin Alex%20Yakunin's gravatar image

Yes, here it is:

StackTrace
at System.Web.Hosting.ISAPIWorkerRequest.SetEndOfSendNotification(EndOfSendNotification callback, Object extraData)
at System.Web.HttpRuntime.ProcessRequestInternal(HttpWorkerRequest wr)
at System.Web.HttpRuntime.ProcessRequestNoDemand(HttpWorkerRequest wr)
at System.Web.HttpRuntime.ProcessRequest(HttpWorkerRequest wr)
at Com.Dynarics.Foundation.Web.Global.TryToReprocessRequest()
in E:\\Sources\\iCandySoftware\\Foundation\\Com.Dynarics.Foundation.Web\\Global.asax.cs:line 170
(Oct 22 '10 at 09:07) Denis Denis's gravatar image

Comment from the author:

Moreover I used reflector and found where error is raised

public override void SetEndOfSendNotification(HttpWorkerRequest.EndOfSendNotification callback, object extraData)
{
    if (this._endOfRequestCallback != null)
    {
    throw new InvalidOperationException();
    }
    this._endOfRequestCallback = callback;
    this._endOfRequestCallbackArg = extraData;
    this._endOfRequestCallbackLockCount = 1;
}

But don't know why :)

// Posting this an an answer was a bit wrong, so I reposted it as a comment.

(Oct 22 '10 at 09:51) Dmitri Maximov Dmitri%20Maximov's gravatar image

2 Answers:

Likely, this happens because ASP.NET was changed after the moment we wrote this code.

TryToReprocessRequest actually makes a hack by pushing request back to ASP.NET processing pipeline. As you see, this hack doesn't work now.

Possible workaround (I didn't try it) is to try setting _endOfRequestCallback of appropriate object (ISAPIWorkerRequest, but you must find the path to that instance) to null before ProcessRequest invocation. Of course, using reflection.

answered Oct 22 '10 at 11:18

Alex%20Yakunin's gravatar image

Alex Yakunin
29714412

1

Great! Your workaround works...at least for IIS 6.. I'll post source of changed TryToReprocessRequest method on Monday. Спасибо за помощь :)

(Oct 22 '10 at 12:20) Denis Denis's gravatar image

Greetings! Thanks god I still remember such stuff from v3.X ;)

(Oct 22 '10 at 13:13) Alex Yakunin Alex%20Yakunin's gravatar image

It seems that I found acceptable solution for my project. Probably that could help to someone else too.

So I added processing of deadlocks in Global.asax.cs Application_Error handler. And in case of exception I just make a Response.Redirect


protected virtual void Application_Error(object sender, EventArgs e)
        {               
                Exception ex = Server.GetLastError().InnerException;
                if (ex is DeadlockException || ex is TransactionIsLockedException)
                {                   HttpContext.Current.Response.Redirect(Request.RawUrl.ToString());
                }
}

answered Oct 22 '10 at 11:15

Denis's gravatar image

Denis
7225

edited Oct 22 '10 at 11:19

This won't work for POST requests - we were aware about this approach, and that was the reason to use a hack instead of this solution.

(Oct 22 '10 at 11:21) Alex Yakunin Alex%20Yakunin's gravatar image
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!
toggle preview

powered by OSQA