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. C#
  4. Cross AppDomain Exception Handling. Plugin architecture. [modified]

Cross AppDomain Exception Handling. Plugin architecture. [modified]

Scheduled Pinned Locked Moved C#
graphicsarchitecturetutorial
4 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.
  • A Offline
    A Offline
    Abdul Gafoor
    wrote on last edited by
    #1

    Hi all, I want to handle a unhandled exception thrown by a plugin running in its own appDomain (ie not Defualt appDomain) in defualt appDomain (host appliation), and then unload the culprit appDomain.. Is it really possible to handle this kind of cross appDomain exception. the exception may occur any time during the life time of plugin appdomain ( say some buttton in the plugin throws some unhandled exception..) please have a look on the sample code given below.. What should i do handle the exception thrown by button1.. I never want to close my host application at any cost. it should continue its execution whatever happens in plugins.. please give me guide lines. //********************* Plug in ******************************* public class BadPlugin: Form,IPlugin { private System.Windows.Forms.Button button1; public StaffList() { InitializeComponent(); } private void InitializeComponent() { this.textBox1 = new System.Windows.Forms.TextBox(); this.button1 = new System.Windows.Forms.Button(); this.SuspendLayout(); // // button1 // this.button1.Location = new System.Drawing.Point(232, 96); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(176, 48); this.button1.TabIndex = 1; this.button1.Text = "button1"; this.button1.Click += new System.EventHandler(this.button1_Click); // // StaffList // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(488, 302); this.Controls.Add(this.button1); this.Controls.Add(this.textBox1); this.Name = "StaffList"; this.ResumeLayout(false); } private void button1_Click(object sender, System.EventArgs e) { throw new Exception("Bad plgin exploded exception"); } } //********************* Plug in Interface ******************************* public interface IPlugin { void Show(); } //******************** Plug in Host Application*************************** try { AppDomain app = AppDomain.CreateDomain("PluginDomain"); IPlugin plugin = (IPlugin)app.CreateInstanceAndUnwrap("SamplePlugins","SamplePlugins.BadPlugin"); plugin.Show(); } catch(Exception ex) { MessageBox.Show(ex.Message); } Thanks and regards 123developer -- modified at 1:06 Tuesday 10th July, 2007

    O 1 Reply Last reply
    0
    • A Abdul Gafoor

      Hi all, I want to handle a unhandled exception thrown by a plugin running in its own appDomain (ie not Defualt appDomain) in defualt appDomain (host appliation), and then unload the culprit appDomain.. Is it really possible to handle this kind of cross appDomain exception. the exception may occur any time during the life time of plugin appdomain ( say some buttton in the plugin throws some unhandled exception..) please have a look on the sample code given below.. What should i do handle the exception thrown by button1.. I never want to close my host application at any cost. it should continue its execution whatever happens in plugins.. please give me guide lines. //********************* Plug in ******************************* public class BadPlugin: Form,IPlugin { private System.Windows.Forms.Button button1; public StaffList() { InitializeComponent(); } private void InitializeComponent() { this.textBox1 = new System.Windows.Forms.TextBox(); this.button1 = new System.Windows.Forms.Button(); this.SuspendLayout(); // // button1 // this.button1.Location = new System.Drawing.Point(232, 96); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(176, 48); this.button1.TabIndex = 1; this.button1.Text = "button1"; this.button1.Click += new System.EventHandler(this.button1_Click); // // StaffList // this.AutoScaleBaseSize = new System.Drawing.Size(5, 13); this.ClientSize = new System.Drawing.Size(488, 302); this.Controls.Add(this.button1); this.Controls.Add(this.textBox1); this.Name = "StaffList"; this.ResumeLayout(false); } private void button1_Click(object sender, System.EventArgs e) { throw new Exception("Bad plgin exploded exception"); } } //********************* Plug in Interface ******************************* public interface IPlugin { void Show(); } //******************** Plug in Host Application*************************** try { AppDomain app = AppDomain.CreateDomain("PluginDomain"); IPlugin plugin = (IPlugin)app.CreateInstanceAndUnwrap("SamplePlugins","SamplePlugins.BadPlugin"); plugin.Show(); } catch(Exception ex) { MessageBox.Show(ex.Message); } Thanks and regards 123developer -- modified at 1:06 Tuesday 10th July, 2007

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

      Bothered to check out the AppDomain members list? http://msdn2.microsoft.com/en-us/library/system.appdomain_members.aspx[^]

      A 2 Replies Last reply
      0
      • O originSH

        Bothered to check out the AppDomain members list? http://msdn2.microsoft.com/en-us/library/system.appdomain_members.aspx[^]

        A Offline
        A Offline
        Abdul Gafoor
        wrote on last edited by
        #3

        Dude, I already had a look on AppDomain members.. if u r pointing to AppDomain.UnhandledException event.. , it is not firing in my case. I have registered this event bfore Application.Run().. in defualt appDomain.. According to MSDN documents, it sholud be fired before the application going to unstable state.. But in my case i am getting the unhanled exception message runtime messagebox.. What i am really missing my code. can you point the specific member you are suggesting. Thanks and regards 123developer

        1 Reply Last reply
        0
        • O originSH

          Bothered to check out the AppDomain members list? http://msdn2.microsoft.com/en-us/library/system.appdomain_members.aspx[^]

          A Offline
          A Offline
          Abdul Gafoor
          wrote on last edited by
          #4

          i didn't get it.. could u please explain that which appDomain member should i concentrate on?

          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