Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Anyway to ignore unhandled errors in config file?

Posted on 2007-11-29
8
Medium Priority
?
537 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 64

Accepted Solution

by:
Fernando Soto earned 2000 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 64

Expert Comment

by:Fernando Soto
ID: 20377328
Does it post an exception name? If so what is it.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 64

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 64

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 Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

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…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Screencast - Getting to Know the Pipeline
Suggested Courses

916 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