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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C#
  4. Protecting from plugin crashes

Protecting from plugin crashes

Scheduled Pinned Locked Moved C#
asp-netdatabasehardwarehelpquestion
4 Posts 3 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.
  • B Offline
    B Offline
    Benny_Lava
    wrote on last edited by
    #1

    Hello, I'm building a plugin system for a hardware communicator system. So a plugin is actually a device communicator and the core program has many plugins that communicate with devices and write something to the database. Now, I have solved many things, I have made a DevicePlugin interface and have dynamically loaded and instantiated the plugins, and it works. The only thing that is bothering me is plugin crashes, for some reasons a plugin can sometimes crash (throw an unexpected exception) and a single plugin can crash my entire system. So my question is is there some way to put the entire plugin assembly intoa try catch so when plugin crashes the core system remains intact. Any help greatly appreciated. Thanks!

    B R 2 Replies Last reply
    0
    • B Benny_Lava

      Hello, I'm building a plugin system for a hardware communicator system. So a plugin is actually a device communicator and the core program has many plugins that communicate with devices and write something to the database. Now, I have solved many things, I have made a DevicePlugin interface and have dynamically loaded and instantiated the plugins, and it works. The only thing that is bothering me is plugin crashes, for some reasons a plugin can sometimes crash (throw an unexpected exception) and a single plugin can crash my entire system. So my question is is there some way to put the entire plugin assembly intoa try catch so when plugin crashes the core system remains intact. Any help greatly appreciated. Thanks!

      B Offline
      B Offline
      BobJanova
      wrote on last edited by
      #2

      Load each plugin into a separate AppDomain and set the AppDomain's UnhandledException handler. Also, unless plugins are starting threads that cause crashes, you can simply wrap a try/catch around the point where you call into the plugin. But if they're talking to devices they probably do.

      B 1 Reply Last reply
      0
      • B BobJanova

        Load each plugin into a separate AppDomain and set the AppDomain's UnhandledException handler. Also, unless plugins are starting threads that cause crashes, you can simply wrap a try/catch around the point where you call into the plugin. But if they're talking to devices they probably do.

        B Offline
        B Offline
        Benny_Lava
        wrote on last edited by
        #3

        Thank you I will try that.

        1 Reply Last reply
        0
        • B Benny_Lava

          Hello, I'm building a plugin system for a hardware communicator system. So a plugin is actually a device communicator and the core program has many plugins that communicate with devices and write something to the database. Now, I have solved many things, I have made a DevicePlugin interface and have dynamically loaded and instantiated the plugins, and it works. The only thing that is bothering me is plugin crashes, for some reasons a plugin can sometimes crash (throw an unexpected exception) and a single plugin can crash my entire system. So my question is is there some way to put the entire plugin assembly intoa try catch so when plugin crashes the core system remains intact. Any help greatly appreciated. Thanks!

          R Offline
          R Offline
          Rob Philpott
          wrote on last edited by
          #4

          To second what Bob says, AppDomains are great for plug-in architectures. As well as providing robust protection of the process if something goes wrong, you can also unload them and that's the only way to 'unplug' a plug-in (craziness aside).

          Regards, Rob Philpott.

          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