Solved

Anyway to ignore unhandled errors in config file?

Posted on 2007-11-29
8
521 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Hi friends,  in this video  I'll show you how new windows 10 user can learn the using of windows 10. Thank you.
CodeTwo Sync for iCloud (http://www.codetwo.com/sync-for-icloud?sts=6554) automatically synchronizes your Outlook 2016, 2013, 2010 or 2007 folders with iCloud folders available via iCloud Control Panel. This lets you automatically sync them with…

911 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

22 Experts available now in Live!

Get 1:1 Help Now