General Topics include: .NET Framework
Note: Most posts can be categorized into one of the forums below, where experts on that topic will be able to help you find a solution to your problem faster and more efficiently.

Go Back  Xtreme .NET Talk > .NET > General > Plugins again


Reply
 
Thread Tools Display Modes
  #1  
Old 09-19-2002, 08:31 AM
quwiltw quwiltw is offline
Contributor
 
Join Date: Sep 2001
Location: Washington, D.C.
Posts: 486
quwiltw is on a distinguished road
Default Plugins again

I've taken a look at the examples for plugin/addins and I've got a prototype of a plugin framework working in VB.NET now. I'm struggling though with one problem.

I've created an interface IPlugin with the appropriate methods. The problem is that I have no way of knowing what the plugin developers call thier implementatio of IPlugin. Currently, I'm able to go through the entire plugin class collection and each classes respective interface collections in order to determine which one implements IPlugin and right now, with only small sample plugins, this is no big deal. But as plugins get larger, this gets messy. I would like to have a better strategy for this, like forcing the name of the implementing class to be something I dictate (which I doubt is possible) or something else. I've thought about maybe maintaining a little xml file that contains all the class implementations for each plugin then I'd only have to investigate the entire assembly once per plugin, but this too seems messy.

Any thoughts are appreciated.
Reply With Quote
  #2  
Old 09-19-2002, 09:19 AM
Thinker's Avatar
Thinker Thinker is offline
Joe Programmer

Preferred language:
VB.NET
 
Join Date: Jul 2001
Location: Fayetteville, Arkansas, USA
Posts: 384
Thinker is on a distinguished road
Default

Quote:
like forcing the name of the implementing class to be something I dictate (which I doubt is possible)
You can choose to ignore any class which doesn't follow some
naming convention you dictate, but it would be breaking the spirit
of OO/Interface programming. I know how I handle it with COM.
I make the user browse to a DLL that is supposed to contain a
class implementing my plugin interface. Then I iterate through the
classes and interfaces, looking for the GUID which is the interface
ID I assigned. I don't know what the equivalent is in .Net, but it
sounds like you are doing something similar.
__________________
Posting Guidelines
Reply With Quote
  #3  
Old 09-19-2002, 09:31 AM
quwiltw quwiltw is offline
Contributor
 
Join Date: Sep 2001
Location: Washington, D.C.
Posts: 486
quwiltw is on a distinguished road
Default

Yep, I can find the implementing class, but it doesn't seem smart to do this each time as I understand reflection is rather expensive. I guess it comes down to

either
1) Take any assembly and investigate it for the implementing class, then store the class name in some plugins.config file the first time, then I've got a clean way to immediately launch a plugin.

or

2) Make a plugin developer also include a little config file that includes their implementing class name.

Having actually typed it out now, option 2 sounds pretty cheesy, I think I'll take option 1 unless you (or anyone else) can think of an option 3/4/5???
Reply With Quote
  #4  
Old 09-19-2002, 09:40 AM
Thinker's Avatar
Thinker Thinker is offline
Joe Programmer

Preferred language:
VB.NET
 
Join Date: Jul 2001
Location: Fayetteville, Arkansas, USA
Posts: 384
Thinker is on a distinguished road
Default

I agree with 1. I wouldn't inspect the assembly more than once.
__________________
Posting Guidelines
Reply With Quote
  #5  
Old 09-20-2002, 07:56 AM
quwiltw quwiltw is offline
Contributor
 
Join Date: Sep 2001
Location: Washington, D.C.
Posts: 486
quwiltw is on a distinguished road
Default

Anyone willing to look at what I've got so far? It's essentially a single solution with 4 projects
1 to define the Plugin Interfaces
1 to implement a IPluginHost
and 2 that implement IPlugin.

I'm sure the code itself can be cleaned up, I'm more concerned about the sanity of the design. Zipped up, it's ~97k. Let me know if you're willing to review it.

EDIT: By the way, I haven't included the config file yet. Currently it inspects the assemblies each and every time.
__________________
--tim
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Choose which plugins are loaded MrLucky Windows Forms 4 04-08-2006 01:14 PM
Making IE plugins. wyrd General 4 09-24-2003 04:30 PM
Please help IE PLugins mickn66 Windows Forms 0 09-15-2003 12:33 PM
More on plugins quwiltw Tutors Corner 2 10-08-2002 01:42 PM

Advertisement:

Powered by liquidweb