473,687 Members | 3,789 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

.Net 2.0 runtime error, Event id: 5000

Hi,
I have made some software that uses one of the COM ports to
communicate with an external device. The software is written in C# and
uses the new SerialPort class in .Net 2.0.
It works perfectly when I use the COM ports that are integrated in my
PC. It also works if I use a COM->RS232 converter as long as I don't
unplug the converter when the software is running. If I unplug the
converter I get a .Net runtime 2.0 error:
http://therkelsen.info/images/blandet/atrack_prob.JPG

This error makes the .Net runtime environment shut down my software
and it seems like there is nothing I can do about it. I can not catch
the "objectDisposed Exception" because it is thrown inside the .Net
environment and makes the environment crash.
Any ideas about what I can do to stop the framework from crashing?
Is this a known bug in the .Net framework?

Best regards,
Kim Therkelsen

Feb 8 '07 #1
5 19534
In .NET 2.0, if there is an unhandled exception in your code, the appDomain
unloads, and "That's the end of that". What you need to do is provide robust
exception handling code in all the places needed to avoid this.
Peter

--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net


"ki***********@ gmail.com" wrote:
Hi,
I have made some software that uses one of the COM ports to
communicate with an external device. The software is written in C# and
uses the new SerialPort class in .Net 2.0.
It works perfectly when I use the COM ports that are integrated in my
PC. It also works if I use a COM->RS232 converter as long as I don't
unplug the converter when the software is running. If I unplug the
converter I get a .Net runtime 2.0 error:
http://therkelsen.info/images/blandet/atrack_prob.JPG

This error makes the .Net runtime environment shut down my software
and it seems like there is nothing I can do about it. I can not catch
the "objectDisposed Exception" because it is thrown inside the .Net
environment and makes the environment crash.
Any ideas about what I can do to stop the framework from crashing?
Is this a known bug in the .Net framework?

Best regards,
Kim Therkelsen

Feb 8 '07 #2
The problem is that the exception can not be caught inside my code -
it is internally in the .Net framework!
And when the .Net Framework "brakes down" it also kills my software.
In fact if I do not press the "Ok" button my software just continues
to run in the background and still works as intended.
In more detail the problem is that I keep trying to write to the port
even though the port has disappeared (USB converter has been
unplugged) - but I am not able to detect exactly when the port
disappears inside the code. Therefore I have a try-catch around this
section but it is unable to catch the objectDisposedE xception which I
believe i generated internally in the .Net Framework and not caught
where it should have been caught.

Kim

On Feb 8, 5:38 pm, Peter Bromberg [C# MVP]
<pbromb...@yaho o.yabbadabbadoo .comwrote:
In .NET 2.0, if there is an unhandled exception in your code, the appDomain
unloads, and "That's the end of that". What you need to do is provide robust
exception handling code in all the places needed to avoid this.
Peter

--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net

"kimtherkel...@ gmail.com" wrote:
Hi,
I have made some software that uses one of the COM ports to
communicate with an external device. The software is written in C# and
uses the new SerialPort class in .Net 2.0.
It works perfectly when I use the COM ports that are integrated in my
PC. It also works if I use a COM->RS232 converter as long as I don't
unplug the converter when the software is running. If I unplug the
converter I get a .Net runtime 2.0 error:
http://therkelsen.info/images/blandet/atrack_prob.JPG
This error makes the .Net runtime environment shut down my software
and it seems like there is nothing I can do about it. I can not catch
the "objectDisposed Exception" because it is thrown inside the .Net
environment and makes the environment crash.
Any ideas about what I can do to stop the framework from crashing?
Is this a known bug in the .Net framework?
Best regards,
Kim Therkelsen
Feb 8 '07 #3
Hi Kim,
Therefore I have a try-catch around this
section but it is unable to catch the objectDisposedE xception which I
believe i generated internally in the .Net Framework and not caught
where it should have been caught.
I suspect you may be correct about this. There is an unfortunate change of
behaviour in the 2.0 framework which kills the app if a thread has an
unhandled exception instead of just quietly killing the thread. This is all
very fine in theory if it is *your* code but if it is a third party
component or perhaps even the framework itself then life gets very
difficult. You can get around this behaviour with an app config file
containing this:
<?xml version="1.0" encoding="utf-8" ?>

<configuratio n>

<runtime>

<legacyUnhandle dExceptionPolic y enabled="true" />

</runtime>

</configuration>

Save it in the same directory as your app and call it something like
myApp.exe.confi g.
This *is* a kludge - there is no guarantee that the component code will
behave correctly in this situation but its worth a try. If it does work you
will then need to find some way of detecting that the event has happened.
Good luck.

Cheers
Doug Forster
Feb 8 '07 #4
Nice, Doug.
Forgot about that - glad you reminded.
Peter
--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net


"Doug Forster" wrote:
Hi Kim,
Therefore I have a try-catch around this
section but it is unable to catch the objectDisposedE xception which I
believe i generated internally in the .Net Framework and not caught
where it should have been caught.

I suspect you may be correct about this. There is an unfortunate change of
behaviour in the 2.0 framework which kills the app if a thread has an
unhandled exception instead of just quietly killing the thread. This is all
very fine in theory if it is *your* code but if it is a third party
component or perhaps even the framework itself then life gets very
difficult. You can get around this behaviour with an app config file
containing this:
<?xml version="1.0" encoding="utf-8" ?>

<configuratio n>

<runtime>

<legacyUnhandle dExceptionPolic y enabled="true" />

</runtime>

</configuration>

Save it in the same directory as your app and call it something like
myApp.exe.confi g.
This *is* a kludge - there is no guarantee that the component code will
behave correctly in this situation but its worth a try. If it does work you
will then need to find some way of detecting that the event has happened.
Good luck.

Cheers
Doug Forster
Feb 9 '07 #5
Thanks Doug!

That stopped the .Net Framework from shutting down the application and
the application keeps working as it should - I can run the scenario
over and over again and it keeps working.

It is quite difficult to detect that the COM port has disappeared.
That means I have to check if the COM port exists every time I want to
access it/every time when I want to read or write something.
Unfortunately there is nothing in the SerialPort class that can tell
if the port has been disposed except you can subscribe to an "port
disposed event" or I can use SerialPort.GetP ortNames() and check if
the port is still in the list. But none of these things will really
solve the problem - the port could have been removed right after I had
done the check and was going to write to the port.

Best regards,
Kim Therkelsen

On 8 Feb., 20:57, "Doug Forster"
<doug_ZAPTHIS_A T_ZAPTHIS_TONIQ _DOT_CO_DOT_NZw rote:
HiKim,
Therefore I have a try-catch around this
section but it is unable to catch the objectDisposedE xception which I
believe i generated internally in the .Net Framework and not caught
where it should have been caught.

I suspect you may be correct about this. There is an unfortunate change of
behaviour in the 2.0 framework which kills the app if a thread has an
unhandled exception instead of just quietly killing the thread. This is all
very fine in theory if it is *your* code but if it is a third party
component or perhaps even the framework itself then life gets very
difficult. You can get around this behaviour with an app config file
containing this:
<?xml version="1.0" encoding="utf-8" ?>

<configuratio n>

<runtime>

<legacyUnhandle dExceptionPolic y enabled="true" />

</runtime>

</configuration>

Save it in the same directory as your app and call it something like
myApp.exe.confi g.
This *is* a kludge - there is no guarantee that the component code will
behave correctly in this situation but its worth a try. If it does work you
will then need to find some way of detecting that the event has happened.
Good luck.

Cheers
Doug Forster

Feb 11 '07 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
6948
by: Aleks A. | last post by:
Greetings all, I'm getting the following 2 errors, back to back, ever couple of days. Anyone encountered anything of the sort? After these 2 errors occur, the asp.net application stops responding. I have to restart the service to get it up and running again. Any way to trace the problem to its root? Any help would be apreciated! Event Type: Error
0
1452
by: raagzcd | last post by:
Hi, I have deployed an ASP.NET application on windows 2003 server. It uses windows authentication .In the code i am using the following code to identify the corpid of the logged in user. string user=User.Identity.Name.ToString(); I am storing the UserID and other credentials in session and using them
0
1889
by: bruce | last post by:
ASP.NET app running for about a year with no problem and suddenly this week it's giving error message. The same as the one decribed by another user. Even stranger is that we only have this problem from some web clients (desktop browser, IE) , some other people do not have problems at all from theirs desktop. Also, some clients can access the web app but some can't! Some can use IE but not Netscape, some can't with both, but there are...
0
4889
by: acb | last post by:
Hi, I have concluded an on-demand series of webcasts forming part of a series titled "Introduction to 2-D Video Game Development" that took place in 2005. The URL is at http://www.microsoft.com/events/series/msdnvideodev.mspx and the corresponding binaries can be found at http://www.digipen.edu/main/Webcast/Introduction_to_2-D_Video_Game_Development.
4
5236
by: news.citenet.net | last post by:
I keep getting the following error message after my web site running 2 or 3 days I share one folder with about 200 domain names Any one can help? --------------------------------------------------------------------------------
8
13096
by: g_man | last post by:
I am trying trap Runtime error 3022 (duplicates) in the click event of a command button that closes the form. I have code in the Form_Error event that does a good job of providing a more meaningful error message than the default. It works in every situation except when the user clicks the close button. I am using Me.Dirty=False to force a save but if there are duplicates I just get the standard Runtime 3022 error message. I am wondering...
0
1302
by: kimtherkelsen | last post by:
Hi, I have made some software that uses one of the COM ports to communicate with an external device. The software is written in C# and uses the new SerialPort class in .Net 2.0. It works perfectly when I use the COM ports that are integrated in my PC. It also works if I use a COM->RS232 converter as long as I don't unplug the converter when the software is running. If I unplug the converter I get a .Net runtime 2.0 error:...
2
4173
by: kplkumar | last post by:
Hi all I am fairly new to windows scheduler. I have an .exe console application that needs to be run 1st of every month. I created a scheduled task in Windows Schduler and called the .exe. The application is supposed to pull some report data and make a webservice call to sent out this data.
4
10819
by: Bernard Borsu | last post by:
Hi ! I have a big problem with a asp.net 2.0 website. I've just upgrade it from asp.net 1.1. In this previous version, no problem at all. Now, i've a recursive error .NET Runtime 2.0 Error - ID Event 5000. Here ise the description in the Application log : EventType clr20r3, P1 w3wp.exe, P2 6.0.3790.3959, P3 45d6968e, P4 system, P5
0
8590
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8524
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9066
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8779
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6450
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5806
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4321
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4541
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
2214
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.