Geeks With Blogs
John Haigh's Blog

A commenter had the question "How do you unload a plugin after loading it?". This is done through the Mono Addin Registry.

Here is some quick code on how to work with the Mono Addins Registry to Enable and Disable an Addin:

This will give you a list of Addins. You could add the Addin's Id to a ListBox as I am doing here and then have buttons to Enable/Disable an Addin.

Addin[] arry = AddinManager.Registry.GetAddins();

foreach (Addin item in arry)
{
this.listBox1.Items.Add(item.Id);
}

This will disable an Addin by Id:

string addinid = this.listBox1.SelectedItem.ToString();
AddinManager.Registry.DisableAddin(addinid);

This will enable an Addin by Id:

string addinid = this.listBox1.SelectedItem.ToString();
AddinManager.Registry.EnableAddin(item);
bool isEnabled = AddinManager.Registry.IsAddinEnabled(item);
MessageBox.Show("Addin enabled " + isEnabled.ToString());

This will determine if an Addin is enabled:

string item = this.listBox1.SelectedItem.ToString();
bool isEnabled = AddinManager.Registry.IsAddinEnabled(item);
MessageBox.Show("Addin enabled " + isEnabled.ToString() );

If you add this to the Sample that I developed you can view the Console messages and see the Addin being loaded an unloaded as you click on the Enable and Disable Addin buttons for a particular Addin. Note that your Addin state(enabled or disabled) will be maintained between Application loads.

Thank you to the commenter who had this question(Enable and Disable an Addin) that gave me the idea to write this post. Posted on Thursday, November 12, 2009 11:20 AM Base Class Library , Mono Addins | Back to top


Comments on this post: Mono Addins - Working with the Mono Addins Registry to Enable and Disable an Addin.

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © John Haigh | Powered by: GeeksWithBlogs.net