shankar_it Posted September 11, 2006 Posted September 11, 2006 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. Quote
Leaders snarfblam Posted September 11, 2006 Leaders Posted September 11, 2006 Maybe you should post the whole try/catch block, because from what you've posted I can't see a possible cause. Quote [sIGPIC]e[/sIGPIC]
shankar_it Posted September 11, 2006 Author Posted September 11, 2006 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(); // } } Quote
shankar_it Posted September 11, 2006 Author Posted September 11, 2006 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 I am using remoting here Quote
Gill Bates Posted September 12, 2006 Posted September 12, 2006 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:if (ex is NullReferenceException) { // do something } else if (ex is MissingMemberException) { // do something } else { // ex is some other type of exception } Quote
shankar_it Posted September 12, 2006 Author Posted September 12, 2006 have any idea of what will i have to use instead of the string "CONCURRENCY_EXCEPTION" Quote
Administrators PlausiblyDamp Posted September 12, 2006 Administrators Posted September 12, 2006 If you do not catch the exception what does it say on the error dialog? Or if you put a breakpoint on the catch block what type does the debugger say ex is? Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
shankar_it Posted September 12, 2006 Author Posted September 12, 2006 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 Quote
shankar_it Posted September 12, 2006 Author Posted September 12, 2006 I did turn off the customErrors in webconfig file <customErrors mode="off" /> and it worked. Quote
Gill Bates Posted September 12, 2006 Posted September 12, 2006 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. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.