Click here to Skip to main content
15,891,204 members
Please Sign up or sign in to vote.
4.13/5 (5 votes)
See more:
When I run an application using Quick test professional an exception is occurred as System.ExecutionEngine exception.

How to handle this?

Initialised an object of a Windows Form as form1
if (form1.ShowDialog(IWin32Window owner) == DialogResult.OK)
at this line exception occurs.

How to handle this?

Reply
Posted
Updated 7-Mar-11 20:20pm
v6
Comments
johannesnestler 7-Mar-11 6:01am    
1. You exception is not "caught"! - Wrap your code in a try-catck block as Ryan Zahra showed you.
2. If you can't solve it - post the complete exception message (ex.ToString()) here
3. The example you showed is wrong: In the line "ptsd.ShowDialog(IWin32Window owner)" you have to give a instance of a IWin32Window to the ShowDialog method. This code can not compile...
-> So show your real code (or a real example), show your complete exception message, do so everytime you want help with an exception. Best Regards
johannesnestler 7-Mar-11 8:11am    
Ok, thank you for showing the code - now I understand your problem better. But I can not give you a hint what's wrong - sorry, code looks good to me. Did you look up the exception help on msdn? http://msdn.microsoft.com/en-us/library/system.executionengineexception(v=vs.80).aspx

-> Sounds bad. Did the message show an additional error code? I would try the code on another machine, maybe the runtime system is corrupted.

You should wrap your code in a try catch block
try
{
     ISchemaEditor ptsd = new ProductionTableSchemaDesigner();
     if (ptsd.ShowDialog(IWin32Window owner) == DialogResult.OK)
     {
     }
}
catch(Exception ex)
{
     //log your exception
}
 
Share this answer
 
Comments
yeshgowda 7-Mar-11 8:00am    
Exception is not caught in catch block.
Sergey Alexandrovich Kryukov 7-Mar-11 13:08pm    
I explain what to do in this case in my Answer, please see.
--SA
Sergey Alexandrovich Kryukov 7-Mar-11 13:09pm    
This is correct, my 5, but OP did not observe exception, so I added the advice in my Answer.
--SA
Espen Harlinn 6-Apr-11 16:04pm    
NIce and simple answer, my 5
Answering follow-up Question in response to the Answer by Ryan:

Exception is not catched caught in catch block.
It simply means one of the two: 1) you report is incorrect; exception is thrown elsewhere, 2) exception is caught but you failed to detect it because wrong exception handler, for example; simply use debugger.

Assuming you would not miss caught exception (case 2); but exception is thrown elsewhere, here what to do:

Catch exception at the very top of the stack of for each thread. Make sure you never block exception from propagation anywhere in the middle; if you catch any exception, always re-throw it in the same block or throw another exception (except the very top where you show exception somehow, never hide it completely). There are very few exclusions from this rule, usually as a last resort in case of some ill-designed 3-rd party libraries.

To get full exception information and locate to source of it, make full exception dump in your top-level exception handler: include exception Stack (most important) and collect exception information on all inner exceptions, recursively (use Exception.InnerException). You can save dump in some file or System.Diagnostics.EventLog. By the way, this is the information you may need to use in your CodeProject Questions.

For System.Windows.Forms.Application, "very top" is in the main UI cycle.
This is how: add a handler to Application.OnThreadException (show exception info in UI); to make this event firing, assign Application.SetUnhandledExceptionMode to UnhandledExceptionMode.CatchException.
Attention! It won't happen by default!

For WPF, there is a similar technique. You need to handle the event Application.DispatcherUnhandledException.

[EDIT]
Additionally or alternatively, handle the events System.AppDomain.UnhandledException and System.AppDomain.FirstChanceException.
Credit to Espen Harlinn for the idea.

See also: How do i make a loop that will stop when a scrollbar reaches the bottom[^]
[END EDIT]



—SA
 
Share this answer
 
v5
Comments
yeshgowda 7-Mar-11 23:51pm    
Thanks for information.If possible can u explain with a sample code about handling of System.ExecutionEngine exception.
Sergey Alexandrovich Kryukov 8-Mar-11 0:49am    
I never get this exception before (like most of exceptions developed in the world, as you understand); here is what I found: http://connect.microsoft.com/wcf/feedback/details/433569/wcf-throws-an-executionengineexception-when-returning-an-array-as-ilist-t

(Please follow this reference to understand the rest of my comment)
After reading this, I remembered that a while ago I found some other problems with WCF serialization which lead me to the idea of limiting complexity of Data Contracts and using different methods of remoting in more complex cases. I never had this exception, therefore.

Said that, do you confirm that you get exception related to OperationContract? (You could figure out if you catch exception and record exception dump following the technique I describe in my Answer, but you also can just spot a problem manually following the description of the problem (see my href above)) You see, I don't have the code to reproduce the problem, but probably you do. As the problem is considered to appear due the .NET bug, you would need to simplify your DataContract and/or OperationContract.

If you have problem figuring out where the problem is, you could extract relevant piece of code and work it into a special test application to pin-point the problem. You can gradually simplify the model until the problem disappear, and than make a step back, and so on until you have a minimal test case where the problem is manifested. If you post such application, maybe I could help you.

--SA
yeshgowda 8-Mar-11 1:10am    
ok.Thanks for suggestion .ok i will check out the problem it may be .net runtime exception
Sergey Alexandrovich Kryukov 8-Mar-11 4:04am    
Please do your research and feel free to ask a follow-up questions.
--SA
Ryan Zahra 8-Mar-11 1:34am    
Excellent explanation. You have my 5. Also thanks for following up my answer as yesterday I lost my connection to the internet. Had a problem with the ISP.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900