Bugs

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: Ayende Rahien (Ayende_at_no.spam)
Date: 04/03/04


Date: Sat, 3 Apr 2004 18:37:42 +0200

Recently I've encountered two highly annoying bugs in the framework,
anyone who knows how to solve them would be most appriciated.

1) I'm trying to do Process.Start(url); and get a Win32Exception, after
quite a bit of testing I found out that the reason for this is that I
didn't have STAThread attribute. Process.Start(url) throws when I don't
have an attribute at all, or when I have MTAThrea, anyone can tell me
why?
I looked around, and it seemed that many other people have encountered
this problem. I've the workaround, but I want to know what is going on
here!

2) The following code throw an exception and abort the program, it
shouldn't!

public static void SetExceptionHandlers()
{
 System.AppDomain.CurrentDomain.UnhandledException+=new
UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);
 System.Windows.Forms.Application.ThreadException+=new
System.Threading.ThreadExceptionEventHandler
(Application_ThreadException);
}

public static void HandleException(Exception ex)
{
 if(ex==null)
  return;
 using(DetailedErrorInfo dei = new DetailedErrorInfo(ex))
 {
  dei.ShowDialog();
 }
}

private static void CurrentDomain_UnhandledException(object sender,
UnhandledExceptionEventArgs e)
{
 HandleException(e.ExceptionObject as Exception);
}

private static void Application_ThreadException(object sender,
System.Threading.ThreadExceptionEventArgs e)
{
 HandleException(e.Exception);
}
[ STAThread()]
public static void Main(string [] args)
{
 SetExceptionHandlers();
 Test();
 Console.WriteLine("Test passeed");

private void Test()
{
 throw new InvalidOperationException("Test");
}

There is nothing wrong here as far as I can tell, but it still will give
me the silly default dialog. The whole point is to have a better dialog
there!

3) Not related to bugs, but does anyone knows whatever there is a way to
know at *runtime* whatever this is a debug or release build?



Relevant Pages

  • Re: been workin hard
    ... private static void out{ ... public static void getTime{ ... int m = now.MINUTE; ...
    (comp.lang.java.help)
  • Re: been workin hard
    ... private static void out{ ... public static void getTime{ ... int m = now.MINUTE; ...
    (comp.lang.java.help)
  • Re: basic GUI question
    ... I haven't read your SSCCE yet, but I thought I'd show you my solution. ... public static void mainthrows Exception ... private static void createAndShowGui() { ...
    (comp.lang.java.programmer)
  • Bugs
    ... Recently I've encountered two highly annoying bugs in the framework, ... public static void SetExceptionHandlers() ... private static void CurrentDomain_UnhandledException(object sender, ...
    (microsoft.public.dotnet.framework)
  • Bugs
    ... Recently I've encountered two highly annoying bugs in the framework, ... public static void SetExceptionHandlers() ... private static void CurrentDomain_UnhandledException(object sender, ...
    (microsoft.public.dotnet.general)