Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Studio
  4. How can vs2005 debugger catch unhandled exceptions in dynamically loaded assemblies?

How can vs2005 debugger catch unhandled exceptions in dynamically loaded assemblies?

Scheduled Pinned Locked Moved Visual Studio
debugginghelptutorialquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Dragan Matic
    wrote on last edited by
    #1

    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

    O 1 Reply Last reply
    0
    • D 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

      O Offline
      O Offline
      originSH
      wrote on last edited by
      #2

      Dragan Matic wrote:

      'exception has been thrown by the target of the invocation'

      Have you looked to see if theres another exception attached to that one? Check in the InnerException property.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups