Skip to main content
gamedev.net
🔒 Locked

Plugin Interface with .NET

Started by NorthWoodsman Dec 13, 2002 at 1:51 PM 0 replies 500+ views
Original Post
NorthWoodsman
NorthWoodsman
Is there any elegant way to load .NET components at run time, without going to ugly hacks? What I''m doing is writing an app in VB .NET, and I''d like to have it be able to load plugins primarily from C++, but it could be written in C# or VB I suppose.
developer
developer
> primarily from C++

Native or Managed C++? That makes difference.


If you''re "consuming" the components in Managed C++ (, C# or VB.Net) language your life is easy. You would then (preferably in a separate DLL) define an interface (or abstract/non-abstract baseclass) that you give to people writing plug-ins.

The plug-in has to reference your assembly, and implement the interface/class you decided.

Your configuration data about the plugin would then consist of the assembly name (custom_plugin.dll) and the class name of the class implemeting your interface.

Your code would call Activator.CreateInstance("custom_plugin", "CustomClass") to create instnces of the class, and you need to use the UnWrap() method to get the instance you will use to call the interface''s methods.

done.



If you''re consuming the components in native C++, your best solution is probably to expose your managed components as COM objects. That involves a few extra steps, you can read more here: http://samples.gotdotnet.com/QuickStart/howto/default.aspx?url=/quickstart/howto/doc/Interop/Building_Samples_COM2NET.aspx

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.