Concurrency_exception

shankar_it

Freshman
Joined
Jul 6, 2005
Messages
46
I am using .net 1.1 and i am trying to catch CONCURRENCY_EXCEPTION and throw a message for that exception using the code

if(ex.Message == "CONCURRENCY_EXCEPTION")
{
MessageBox.Show("This record has been updated since you opened it. Please close the record and re-open it.");
}

it works when i try to compile it in my machine but after deploying the code it does not catch this error.It just give a general "Server encountered an internal error".

Can any one help me in this.
 
Maybe you should post the whole try/catch block, because from what you've posted I can't see a possible cause.
 
private void HandleUnhandledExceptions(Exception ex)
{
MessageBox.Show(ex.ToString());
if(ex.Message == "CONCURRENCY_EXCEPTION")
{
MessageBox.Show("This record has been updated since you opened it. Please close the record and re-open it.");
}
else
{
GlobalUI.DisplayFatalErrorMessage();
}

if((ex.Message != "SERVER_EXCEPTION") && (ex.Message != "CONCURRENCY_EXCEPTION"))
{
ServiceObj.LogClientException(ex);
}
// //TODO if an exception occurs inside frmMain, this would close active form which would not be expected behavior.
// //need to resolve.
// if (this.ActiveMdiChild != null)
// {
// this.ActiveMdiChild.Dispose();
// }
}
 
am using remoting here and when i tryed to google for this problem in internet some ppl have sugested to use

<customErrors mode="on" /> and i have used this in the webconfig file of the server but it still dosen't work

shankar_it said:
I am using remoting here
 
There's still not enough to work with. But, if I were you, I would not drive your logic off of string comparisons with the .Message property. Do something like this instead:
C#:
if (ex is NullReferenceException)
{
    // do something
}
else if (ex is MissingMemberException)
{
    // do something
}
else
{
    // ex is some other type of exception
}
 
It gives a error called "message: 'Server encoutered an internal error. for more information, turn on the customErrors in server's .config file'" when i deploy it in the server with the ex as "sever_exception" but when i compile it in the local machine it works properly and the ex vaule is "concurrency_exception" and it goes into the if block and displays the message i have typed
 
If you were to use my approach, the Message would not matter. Using string comparisons like that to drive logic is generally a bad idea.
 
Back
Top