Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / November 2006

Tip: Looking for answers? Try searching our database.

Windows application terminates (exits) abnormally

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Daniel - 15 Nov 2006 09:52 GMT
Hello!

I am having a problem with a windows application that abnormally terminates
itself. The application is a multi threaded .NET 1.1 application, and can
briefly be described as follows:

Call the thread running the GUI "A". When user clicks a button a new thread
"B" is created and started. "B" does a lots of work, among others transmitts
data via a USB-CAN-interface. At the end of "B" a paper label is printed
using methods provided by the framework
(System.Drawing.Printing.PrintDocument)

If I removes the printing routines no error occures, but when the printer is
enabled the application sometimes terminates. No error codes, no unhanlded
exceptions, no messages.

Does anyone have a clue what causes this problem?

Regards, Daniel
Dave Sexton - 15 Nov 2006 10:01 GMT
Hi Daniel,

.NET Framework versions earlier than 2.0 swallow exceptions that occur on
background threads.

I suggest wrapping your printing code in a try..catch block.  Read the
documentation for the printing methods that you use to determine which
exceptions may be thrown and catch the ones from which your application can
recover.

To aid in debugging, you may want to add a try..catch-all exception handler
that logs any exception and then rethrows them (even those exceptions not
being handled in your code).

Signature

Dave Sexton

> Hello!
>
[quoted text clipped - 15 lines]
>
> Regards, Daniel
Daniel - 15 Nov 2006 10:15 GMT
Hello!

Thank you for a quick reply! Actually there are commonly no errors when
printing the label. Sometimes the error occures here, but not all the time.
Very often the error occures when user starts "B" agin.

I have try-catch blocks around my printing code, around the thread start
method and even around Main, no exceptions are thrown (At least no managed
exceptions). I also loggs all threads via Application.ThreadException and
Application.ThreadExit. As I can se, the printing thread (whicth is straed by
the framework) exits normally.

Another strange this is that in some cases the entire computer is
restarted...!

Daniel Carlson

> Hi Daniel,
>
[quoted text clipped - 29 lines]
> >
> > Regards, Daniel
Dave Sexton - 15 Nov 2006 10:22 GMT
Hi Daniel,

That does sound bad :|

Maybe it's a driver error.

The other thing I can recommend is to search the newsgroups and Microsoft's
knowledge base for problems like yours (if you haven't already) and then
solicit the help of Microsoft if that doesn't help you to solve the problem.

GL!

Signature

Dave Sexton

> Hello!
>
[quoted text clipped - 52 lines]
>> >
>> > Regards, Daniel
Ciaran O''Donnell - 15 Nov 2006 10:53 GMT
The framework 1.1 has an issue where it sometimes isnt ale to convert an
Access Violation into a .NET exception to throw and therefore the CLR is
terminate immediatly by windows without 1 more line of code running. I had
this for a long time with a data access rountine which would sometimes make
the application just dissappear like it was killed in task manager, I used to
have a link to the KB article about it but this was about 3 years ago now so
thats long gone.
Try handling System.Windows.Forms.Application.ThreadException event to see
if thats fired. Secondly, try running the thread inside a new app domain and
handling the unhandled exception event on the app domain from the form. It be
that the AppDomain is kill rather than the whole process.
I remember this one being a killer.

Ciaran O'Donnell

> Hello!
>
[quoted text clipped - 15 lines]
>
> Regards, Daniel
Daniel - 15 Nov 2006 14:03 GMT
Thank you for this post! This is the first post that is helpful to me! I have
search for infomration for over one week now...

I handle the System.Windows.Forms.Application.ThreadException event with no
result. No exceptions are thrown. I will try to run my application from
another domain and see what that gives.

A question though: Do you think this is solved in 2.0 of the framework? Or
at least give me a more stabel termination?

Daniel Carlson

> The framework 1.1 has an issue where it sometimes isnt ale to convert an
> Access Violation into a .NET exception to throw and therefore the CLR is
[quoted text clipped - 30 lines]
> >
> > Regards, Daniel
Ciaran O''Donnell - 15 Nov 2006 15:01 GMT
I have never had it happen on 2.0 and think I remember something about it
being sorted in 2.0. I have been building a big Winforms app in 2.0 for the
last year and it hasnt happened to me once.

Ciaran O'Donnell

> Thank you for this post! This is the first post that is helpful to me! I have
> search for infomration for over one week now...
[quoted text clipped - 42 lines]
> > >
> > > Regards, Daniel
Daniel Carlson - 15 Nov 2006 16:01 GMT
I belive this is the article you requested...

http://support.microsoft.com/kb/823140/

Daniel Carlson

> I have never had it happen on 2.0 and think I remember something about it
> being sorted in 2.0. I have been building a big Winforms app in 2.0 for the
[quoted text clipped - 48 lines]
> > > >
> > > > Regards, Daniel

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.