473,471 Members | 4,625 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

AssemblyLoad and Unhandled Exceptions

Hi All,

I am subscribed to the AppDomain.CurrentDomain.AssemblyLoad event,
which fires whenever a new assembly is loaded. Our application loads an
assembly, then through this event, checks to see that the assembly
conforms to a set of rules. If the assembly does not conform, then I
throw an exception that (for now) should cause the whole application to
come to a crashing halt, as it is unhandled by any of my code.

However the problem is, and you don't hear this everyday, but "My
application ISN'T crashing!". It appears as though the whoever is
calling the AssemblyLoad event, is also catching my exception. I dont
think this is normal, or intended. I cant see what else could be doing
it.

Anyway hopefully I have it all wrong, and some "kind soul" out there
can sort me out.

Waiting with anticipation,
Shane.

Here is some sample code to illustrate the problem. It was an example
console app, you will need to replace C:\src\bin\Debug\SomeAssembly.dll
with a path to some assembly on your machine if you wish to run it. You
will see that the application runs perfectly fine, where I believe it
should fall in a heap:

BTW: Is there a formating block I can put around code when posting?

using System;
using System.Reflection;

namespace TestConsoleApplication1
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
AppDomain.CurrentDomain.UnhandledException += new
UnhandledExceptionEventHandler(CurrentDomain_Unhan dledException);
AppDomain.CurrentDomain.AssemblyLoad += new
AssemblyLoadEventHandler(CurrentDomain_AssemblyLoa d);
Assembly.LoadFrom( @"C:\src\bin\Debug\SomeAssembly.dll" );

Console.WriteLine( "Press Enter to Exit: " );
string farts = Console.ReadLine();
}

private static void CurrentDomain_UnhandledException(object sender,
UnhandledExceptionEventArgs e)
{
Console.WriteLine( "Wow, the exception was unhandled, and finally
arrived here. Yeah, Yeah Yeah!" );
}

private static void CurrentDomain_AssemblyLoad(object sender,
AssemblyLoadEventArgs args)
{
throw new Exception( "Here is the Exception" );
}
}
}

Nov 29 '05 #1
0 960

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

Similar topics

5
by: terry | last post by:
Hi, Question: When using Framesets and Server.Transfer in the Application_Error event handler is there a mechanism to get the error page to display in the total view of the browser not just in...
4
by: Frank | last post by:
Hi, I made a handler for unhandled errors. But before that is executed, VB.NET gives me the standard error window. In VB6 there was a setting (errortrapping) about handling errors in the design...
5
by: Lucvdv | last post by:
Can someone explain why this code pops up a messagebox saying the ThreadAbortException wasn't handled? The first exception is reported only in the debug pane, as expected. The second (caused by...
5
by: Samuel R. Neff | last post by:
When you have an unhandled exception in vb.net how do you view the exception information in the debugger? In C# the debugger creates a local variable that points to the exception and you can...
5
by: Sam Loveridge | last post by:
Hi All. I'm hoping someone can point me in the direction of a solution to unhandled exceptions in MDI child forms causing the application to crash. I've found various articles describing a...
0
by: Colmeister | last post by:
I recently read Jason Clark's excellent article on Unhandled Exceptions (http://msdn.microsoft.com/msdnmag/issues/04/06/NET/default.aspx) and have attempted to incorporate the features he talks...
2
by: Bob | last post by:
I MUST be able to trap unhandled exceptions, bring the thread to a routine that then closes the thread on which the execption occurred without closing or affecting the other threads. Think of an...
3
by: Andreas van de Sand | last post by:
Hi everyone, I've got an application which uses a custom exception handler and to avoid unhandled exceptions I've got a try{}catch (Exception){} block around the main Application.Run(...). ...
20
by: joseph_gallagher | last post by:
Hi, I've recently ported a .Net 1.1 application to .Net 2.0 and the one new feature that is getting on my nerves is that when there is an unhandled exception the application completely crashes,...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
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.