Plugin dll possible in C#?

W

wannabe geek

Hey, could anybody tell me how to make plugin dll files for an application
and make the application compatible with them? I just need a way for the
library to somehow link to the application or vice versa. In my thoughts, the
application has no knowledge of the library, and so cannot link to it. Yet
the library code is not running and so cannot link to the app. Is there a way
to link the two on startup or something? I have no project so can just give
me class names that I can change to my own later.
 
S

Scott M.

wannabe geek said:
Hey, could anybody tell me how to make plugin dll files for an application
and make the application compatible with them? I just need a way for the
library to somehow link to the application or vice versa. In my thoughts,
the
application has no knowledge of the library, and so cannot link to it. Yet
the library code is not running and so cannot link to the app. Is there a
way
to link the two on startup or something? I have no project so can just
give
me class names that I can change to my own later.

You can only make a "plug in" or "add in" to a program that was designed
with external interfaces (a public API) for you to "plug" or "add" into.

Since you haven't told us what application you want to write a plug in for,
how could we possibly give you instructions on how to do it?

-Scott
 
T

Tom Shelton

Hey, could anybody tell me how to make plugin dll files for an application
and make the application compatible with them? I just need a way for the
library to somehow link to the application or vice versa. In my thoughts, the
application has no knowledge of the library, and so cannot link to it. Yet
the library code is not running and so cannot link to the app. Is there a way
to link the two on startup or something? I have no project so can just give
me class names that I can change to my own later.

You usually have a intermediary library that defines the interfaces that a
plugin is to implement. You also have to have a way to locate the plugin dlls
- like putting them in a common subfolder, etc.

I suggest though, that if you are working with .NET 3.5 you take a look at the
system.addin namespace, as it can help with a lot of the internal plumbing
that is needed to fully implment a plugin system (such as dynamic
loading/unloading of assemblies).
 
J

Jesse Houwing

* wannabe geek wrote, On 17-10-2009 16:21:
Hey, could anybody tell me how to make plugin dll files for an application
and make the application compatible with them? I just need a way for the
library to somehow link to the application or vice versa. In my thoughts, the
application has no knowledge of the library, and so cannot link to it. Yet
the library code is not running and so cannot link to the app. Is there a way
to link the two on startup or something? I have no project so can just give
me class names that I can change to my own later.

Hmm a quick google gives a number of viable links, including some
(albeit older) articles on msdn.

http://www.google.nl/search?q=.net+plugin+framework
 
W

wannabe geek

Hi Scott,

Um, there is no existing app. I want to make my own custom application and
dll plugins so I don't have to implement all possible functions that I could
wish to use, and also keep improving the application without touching it.
 
T

Tom Shelton

Hi Scott,

Thank you * 1000!!!!!!!

You know - if your using 2008, then I highly recommend that you look into
System.AddIn. Plugin support is now in the framework - which is a good thing
if you need more then a simple implementation. For instance, that
architecture in that article does not support the ability to unload a plugin.
That is actually a fairly complex thing to support correctly.
 
W

wannabe geek

Tom Shelton said:
You know - if your using 2008, then I highly recommend that you look into
System.AddIn. Plugin support is now in the framework - which is a good thing
if you need more then a simple implementation. For instance, that
architecture in that article does not support the ability to unload a plugin.
That is actually a fairly complex thing to support correctly.

Yes, I am using VCE 2008, but WHY should i be using System.AddIn? I have no
need to unplug my plugins. Is there a large performance increase? Is it easy
to implement? Less error-prone? If it is those, especially the last two then
could you give me some tips?
 
K

kndg

wannabe said:
Yes, I am using VCE 2008, but WHY should i be using System.AddIn? I have no
need to unplug my plugins. Is there a large performance increase? Is it easy
to implement? Less error-prone? If it is those, especially the last two then
could you give me some tips?

Hi,

Because it promotes good design principle.
Before, I had use the traditional method which involve reflection and it
works. But when you publish your interface to the public, then it is
cast into stone. Break the interface - all the plugins will go kaboom.

System.AddIn support versioning, so when you have to make changes to the
interface (contract), you just create a proper adapter and your old
plugin still run happily.

Although it require a lot of steps to create a simple plugin, the effort
is worthwhile. Also, it is not hard to learn, probably will take you
just one day to implement it (probably less).

Here is MSDN article detailing about System.AddIn
http://msdn.microsoft.com/en-us/library/bb384241.aspx

Regards.
 
T

Tom Shelton

Yes, I am using VCE 2008, but WHY should i be using System.AddIn? I have no
need to unplug my plugins. Is there a large performance increase? Is it easy
to implement? Less error-prone? If it is those, especially the last two then
could you give me some tips?

Just to add to the other response... You might not need plugin unloading, but
it is not a bad thing to properly isolate plugins from the main app domain so
that a misbehaving plugin doesn't take down your app. Again, this is not as
easy a task to get right as it may sound.

I'm not telling you not to use the traditional way, I'm suggesting that you
take a look at System.AddIn and evaluate it's features/benifits and see if it can do
anything to improve the design/stability of your application.
 
W

wannabe geek

Hi Tom,
If you can tell me in 100 words (excluding any code) how to execute a method
of a specific plugin class using System.AddIn please do. Otherwise forget it.
I looked at System.AddIn but I didn't bother really testing it. The other
method seems to work great.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top