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 / Windows Forms / WinForm General / July 2006

Tip: Looking for answers? Try searching our database.

Unhandled exception ignored?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
sb - 10 Jul 2006 15:22 GMT
In the simplified code below, shouldn't the thrown exception cause the app
to terminate since it is unhandled?  It doesn't seem to do anything in Debug
or Release mode.  I do get a first-chance exception message in the debugger
but that's it.  Something seems to be intercepting the exception and
handling it...but I don't know what.

Any info would be appreciated :)
-sb

// Entire program
using System;
using System.Windows.Forms;

static class Program
{
   [STAThread]
   static void Main()
   {
       Application.Run(new Form1());
   }
}

public class Form1 : Form
{
   public Form1()
   {
       this.AllowDrop = true;
       this.DragDrop += new
System.Windows.Forms.DragEventHandler(this.Form1_DragDrop);
       this.DragOver += new
System.Windows.Forms.DragEventHandler(this.Form1_DragOver);
   }

   private void Form1_DragOver(object sender, DragEventArgs e)
   {
       e.Effect = DragDropEffects.Copy;    // We'll accept any kind of drop
   }

   private void Form1_DragDrop(object sender, DragEventArgs e)
   {
       throw new InvalidOperationException("DragDrop exception.");  //
nothing happens here
   }
}
Stoitcho Goutsev (100) - 11 Jul 2006 14:15 GMT
DragDrop event called as a result of COM drag and drop operation and is
called directly by COM. If any exception should happen they are probably
re-routed to the caller (which is not your application) and it looks like
they get swallowed.

Signature

HTH
Stoitcho Goutsev (100)

> In the simplified code below, shouldn't the thrown exception cause the app
> to terminate since it is unhandled?  It doesn't seem to do anything in
[quoted text clipped - 41 lines]
>    }
> }
sb - 11 Jul 2006 22:41 GMT
Thanks for the reply but what does this have to do with COM?  I thought
drag/drop events were just normal windows messages (ie WM_DROPFILES).  I'll
have to look into that some more I guess.  The wierd part is that if I wrap
the exception in a try/catch block within the Form.DragDrop event, I can
intercept it just like any other exception.  I thought another thread might
be handling the exception but the ManagedThreadID within the method is the
same as the rest of the application.

I would like to understand this issue better...I just don't get it :)

-sb

> DragDrop event called as a result of COM drag and drop operation and is
> called directly by COM. If any exception should happen they are probably
[quoted text clipped - 46 lines]
>>    }
>> }

Rate this thread:







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.