Solved

Anyway to ignore unhandled errors in config file?

Posted on 2007-11-29
8
522 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 63

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 63

Expert Comment

by:Fernando Soto
ID: 20377328
Does it post an exception name? If so what is it.
0
Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

 
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
 
LVL 63

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 63

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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Introduction Hi all and welcome to my first article on Experts Exchange. A while ago, someone asked me if i could do some tutorials on object oriented programming. I decided to do them on C#. Now you may ask me, why's that? Well, one of the re…
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…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

809 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