If you explain how and why these functions will be called it is much easier to give a satisfactory answer. As for not being able to get reflection to work, I don't know where you might have run into problems and you did not explain. Reflection might be the answer you are looking for, I merely suggested you look into other options as well.
As for the example you requested, well, since I am such a nice guy, here is a bunch of code. Like I said, this isn't a good beginner project. I'm assuming that you are familiar with inheritance and interfaces (especially since you are writing a plug-in app), and that you know how to use the System.Activator class and the PropertyGrid control.
Since we will be creating command-based plug-in, we would want to write a command-based-plug-in-interface as a base for command-based plug-ins.
The commands will be invoked by a string (which specifies the name of the command) and if there are any arguments, they can be passed using a special class for arguments for that command. You will see what I mean by that in a moment. Here is our interface:
Visual Basic:
Interface ICommandInterface
Function GetCommands() As CommandInfo() 'Gets an array of CommandInfo objects
Function SendCommand(command As String, args As Object) As Object
End Interface
We need to declare a class that can describe a command:
Visual Basic:
Public Structure CommandInfo
Public Name As String
Public ArgType As System.Type
Public Sub New(Name As String, ArgType As System.Type)
Me.Name = Name
Me.ArgType = ArgType
End Sub
End Structure
Note the ArgType. This specifies the class that is used to pass arguments to a command. This is very similar to the way arguments are passed to event handlers: A click event receives an EventArgs object, and a MouseDown event receives a MouseEventArgs. A label edit in a list view receives a LabelEditEventArgs. Get it? You will see how it works soon.
Now, pretend we are making an graphics editing application which supports graphic filter plug-ins. We can actually use our ICommandInterface as is because it is flexible enough that we don't need to add any methods--everything can be done through the SendCommand method.
This is how a graphics filter plugin will work: the GetCommands function will return a list of commands that represent filters that the plug-in supports, and you call SendCommand to use a filter. Simple, no?
Here is our plug-in code:
Visual Basic:
Public Class BitmapFilterPlugIn
Implements ICommandInterface
Public Function GetCommands() As CommandInfo() Implements ICommandInterface.GetCommands
'We don't have any filters yet, so return an empty array
Return New CommandInfo(0) {}
End Function
Public Function SendCommand(ByVal command As String, ByVal args As Object) As Object Implements ICommandInterface.SendCommand
'We don't have any filters yet, so do nothing and return nothing.
Return Nothing
End Function
End Class
[/vB]
It doesn't look like much yet, but we will add filters. First, we need to look at those argument objects I was talking about. Since all filters will work on Bitmap objects, we will need to pass bitmaps to our filters. Let's define a base class for passing arguments to our filters.
[CODE=visualbasic]
Public Class FilterOptions
Public TargetImage As Bitmap
End Class
Now, let's create a filter. We can do something simple, like Brightness. Generally you would pass a floating-point number to a brightness filter that represents the percentage of brightness the filter is to apply. Here is a class that we can pass to the Brightness filter:
Visual Basic:
Public Class BrightnessOptions
Inherits FilterOptions
'Create a property for a filter option
Dim _Brightness As Single
Public Property Brightness() As Single
Get
Return _Brightness
End Get
Set(ByVal value As Single)
_Brightness = value
End Set
End Property
End Class
Now, let's incorporate that filter into our filter plug-in.
Visual Basic:
Public Class BitmapFilterPlugIn
Implements ICommandInterface
Public Function GetCommands() As CommandInfo() Implements ICommandInterface.GetCommands
'Return an array that lists our commands and the arguments they require
Return New CommandInfo() { _
New CommandInfo("Brightness", GetType(BrightnessOptions)) _
}
End Function
Public Function SendCommand(ByVal command As String, ByVal args As Object) As Object Implements ICommandInterface.SendCommand
'Perform the appropriate action based on the command string
Select Case command.ToUpper()
Case "BRIGHTNESS"
Brighten(CType(args, BrightnessOptions).TargetImage, _
CType(args, BrightnessOptions).Brightness)
End Select
' Most likely, none of our filters will need to return anything
Return Nothing
End Function
Public Sub Brighten(ByVal image As Bitmap, ByVal brightness As Single)
'This function applies the filter
End Sub
End Class
Now everything should come together. To use the plug-in, first you would call GetCommands(), which would return an array with one CommandInfo. That CommandInfo would tell you that there is a command named Brightness which requires a BrightnessOptions object.
We will list Brightness in our plug-in menu. When the user selects the Brightness filter, we will use the System.Activator class to create a BrightnessOptions object. We will assign the image the user is editing to the BrightnessOptions object's TargetImage field, and then we will put the BrightnessOptions object in a property grid where the user can edit the Brightness property (or whatever options there are for other filters). You will most likely want to show the property grid on a dialog form.
Finally, we call the SendCommand function, passing the string "Brightness" and our BrightnessOptions object. The plug-in calls the Brighten() function, which actually applies the filter, and that's it.