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. Visual Studio doesn't understand proxied code?

Visual Studio doesn't understand proxied code?

Scheduled Pinned Locked Moved Visual Studio
csharpvisual-studiocomsysadmindebugging
2 Posts 1 Posters 2 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.
  • C Offline
    C Offline
    Chris Copeland
    wrote on last edited by
    #1

    So I've been working on a personal project, and it's come to the point where I'm sitting back, looking at it, and thinking "hey, let's maybe make this a little more versatile". So I've been working on a small library whose only function is to proxy some of the classes I've made, to automate their behaviour. One of these modifications is adding a [Suppress] attribute (C#) to a method, property or constructor, and having the method bodies encapsulated in a try..catch block to suppress exceptions which aren't necessarily important (for some optional methods where execution can continue regardless) So I generated the code using the TypeBuilder class, and created an override method for the virtual method, add the try block, call the base method, add the catch block, and do any returns as necessary. The exception is caught by this proxied method (I added a Debug.WriteLine to confirm the catch block is working), however Visual Studio still breaks in the method which raised the exception! I'm guessing that because Visual Studio doesn't have visibility/understanding of what the proxied class is doing, it just processes the base method as usual and breaks. Is there a way, at all, to stop this behaviour from happening? I mean, it's great for situations where I don't want the exceptions suppressed, but the whole point of adding the [Suppress] attribute was to specifically signal that I don't care if an exception is thrown!

    MQ / Tor.NET / Angry Potato

    C 1 Reply Last reply
    0
    • C Chris Copeland

      So I've been working on a personal project, and it's come to the point where I'm sitting back, looking at it, and thinking "hey, let's maybe make this a little more versatile". So I've been working on a small library whose only function is to proxy some of the classes I've made, to automate their behaviour. One of these modifications is adding a [Suppress] attribute (C#) to a method, property or constructor, and having the method bodies encapsulated in a try..catch block to suppress exceptions which aren't necessarily important (for some optional methods where execution can continue regardless) So I generated the code using the TypeBuilder class, and created an override method for the virtual method, add the try block, call the base method, add the catch block, and do any returns as necessary. The exception is caught by this proxied method (I added a Debug.WriteLine to confirm the catch block is working), however Visual Studio still breaks in the method which raised the exception! I'm guessing that because Visual Studio doesn't have visibility/understanding of what the proxied class is doing, it just processes the base method as usual and breaks. Is there a way, at all, to stop this behaviour from happening? I mean, it's great for situations where I don't want the exceptions suppressed, but the whole point of adding the [Suppress] attribute was to specifically signal that I don't care if an exception is thrown!

      MQ / Tor.NET / Angry Potato

      C Offline
      C Offline
      Chris Copeland
      wrote on last edited by
      #2

      And just like that, I found the cause of the problem almost as soon as I posted this message. It turns out there's a Visual Studio setting called "Just My Code" under the Tools > Options > Debugging > General window. Turning this off means that Visual Studio accounts for externally generated code, and therefore factors in the try..catch which I added in the proxied type. This message seems like a bit of a waste, but I suppose it's here if anyone else needs it.

      MQ / Tor.NET / Angry Potato

      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