Solved

Anyway to ignore unhandled errors in config file?

Posted on 2007-11-29
8
520 Views
Last Modified: 2010-04-15
I'm developing an app using both SQL Server and IBM provider.
I'm getting this error and seems like it's from IBM and we need to get a hotfix from them. Until then, is there a way to catch/ignore unhandled exceptions in App.Config (i'm using windows console).

Code works fine , just get the error at the end. Need to ignore the error until we get the hotfix.

This thread talks about the error and mentions below but i dont see that legacy option. I added it but got an error.
<runtime>
   <legacyUnhandledExceptionPolicy enabled="1"/>
  </runtime>

0
Comment
Question by:Camillia
  • 4
  • 4
8 Comments
 
LVL 62

Accepted Solution

by:
Fernando Soto earned 500 total points
ID: 20377143
This code here is for ASP.Net, Web Applications not for Windows Form or Console applications.

<runtime>
   <legacyUnhandledExceptionPolicy enabled="1"/>
</runtime>

To avoid the exception just place the offending code in a Try/Catch block.

        Try
            'Place statement/s that cause the exception here. Program
            ' continues on the first statement after the End Try.
        Catch ex As Exception

        End Try

Fernando
0
 
LVL 7

Author Comment

by:Camillia
ID: 20377187
try catch wont work since it happens at the end of the app. No where specific. At the very very last line of the app when it's closing...

Getting the hotfix . I'll see if that would fix it.
0
 
LVL 62

Expert Comment

by:Fernando Soto
ID: 20377328
Does it post an exception name? If so what is it.
0
 
LVL 7

Author Comment

by:Camillia
ID: 20377406
i thought i posted the link , i hadnt:

http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=115170

Error is :
System.ObjectDisposedException was unhandled
Safe handle has been closed
0
6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

 
LVL 62

Expert Comment

by:Fernando Soto
ID: 20377683
Hi Farzadw;

If you structure your console application like this then you should not get the error being displayed.

Fernando
using System;

using System.Collections.Generic;

using System.Text;
 

namespace ConsoleApplication3

{

    class Program

    {

        private static void DoTheRealWorkHere()

        {

            // Do you real work here

        }

        

        static void Main(string[] args)

        {

            try

            {

                DoTheRealWorkHere();

            }

            catch (Exception ex)

            {
 

            }

        }

    }

}

Open in new window

0
 
LVL 7

Author Comment

by:Camillia
ID: 20378415
let me try it.
0
 
LVL 7

Author Comment

by:Camillia
ID: 20392135
tried it and still throws the error. I havent applied IBM's fix. I'm using this code for the Data Access layer
http://aspalliance.com/837  
and there's no try-catch in his code. I think the error is from IBM's provider when it connects or something (i read something like that).

I****  got a more detailed error:

Unhandled Exception: System.ObjectDisposedException: Safe handle has been closed
   at System.Runtime.InteropServices.SafeHandle.DangerousRelease()
   at System.Threading.RegisteredWaitHandleSafe.Finalize()


Which lead me to this site:
http://msdn2.microsoft.com/en-us/library/system.runtime.interopservices.safehandle.dangerousrelease(VS.80).aspx

Wonder if I need to code for safe handle.

*** told my manager about the fix and he's in la la land somewhere. If I could get around it with code, that would be great. Otherwise, he needs to deal with it.

0
 
LVL 62

Expert Comment

by:Fernando Soto
ID: 20392456
Sorry but I have not used this configuration before and can not help in this matter.
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
C# Problem Solving Execerscise 5 42
Get String split 5 33
Showdialog 8 21
Passing a form as a parameter to an external class 1 12
Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now