How can vs2005 debugger catch unhandled exceptions in dynamically loaded assemblies?
-
I have a problem how to catch unhandled exceptions in vs2005 in dynamically loaded assemblies, for instance, the following line if not defined in try/catch block will cause the debbugger to catch the unhandled exception, show the appropriate message and position to the problematic line. int i = Convert.ToInt32("asdfas"); On the other hand, if I have an assembly that is loaded at run-time, for instance like this: Assembly a = Assembly.Load(strAssembly); Type ObjectType = a.GetType(strClass); object obj = Activator.CreateInstance(ObjectType); MethodInfo mi = ObjectType.GetMethod("SomeMethod", pars); mi.Invoke(obj, null); and there is an unhandled exception somewhere in the assembly, VS2005 will not catch that exception (even if assembly is compiled as DEBUG and can be debugged into) but instead 'mi.Invoke' will exit with generic exception 'exception has been thrown by the target of the invocation'. Is there a way for VS2005 to catch these exceptions and position to problematic line like it does with non run-time loaded assemblies? Dragan Matic
-
I have a problem how to catch unhandled exceptions in vs2005 in dynamically loaded assemblies, for instance, the following line if not defined in try/catch block will cause the debbugger to catch the unhandled exception, show the appropriate message and position to the problematic line. int i = Convert.ToInt32("asdfas"); On the other hand, if I have an assembly that is loaded at run-time, for instance like this: Assembly a = Assembly.Load(strAssembly); Type ObjectType = a.GetType(strClass); object obj = Activator.CreateInstance(ObjectType); MethodInfo mi = ObjectType.GetMethod("SomeMethod", pars); mi.Invoke(obj, null); and there is an unhandled exception somewhere in the assembly, VS2005 will not catch that exception (even if assembly is compiled as DEBUG and can be debugged into) but instead 'mi.Invoke' will exit with generic exception 'exception has been thrown by the target of the invocation'. Is there a way for VS2005 to catch these exceptions and position to problematic line like it does with non run-time loaded assemblies? Dragan Matic