The plugin is a program written by a certain specification application interface.
* Compiled DLL files cannot change the file name, otherwise "Find named 'CHildFRM'" will appear in list list without matching "* This example is in the Windows operation mode, ASP.NET is also Similarly, the reading of the file name is as follows: string sv = configurationSettings.appsettings ["file name"]; // Read from Web.config (Test)
1. Create a ClassLibray program, define an interface as a plugin interface in this classlibray This DLL will provide public interface definitions for Windows Programs main.exe and plug-in ClassLibray // Name Infbase.dllnamespace Infbase {////
3. Creating a plugin Childfrm1.dllnamespace infbase {public class childfrm: ichildFormBase {public childfrm () {} // Implement the OPEN (String S) method of the plug-in interface definition public int open (string s) {return 0;}}} 4. Windows programs use Main.exe plugin: if (openFileDlg.ShowDialog () == DialogResult.OK) {string filename = openFileDlg.FileName; // Load a ClassLibrary: plug Assembly a = Assembly.LoadFrom (filename); // Using Namespace, use the .NET reflex mechanism to create objects // so, all plugins use a regular namespace, such as using the same namespace, or to facilitate the Object Obj in the main program. = a.createInstance ("infbase.childfrm"); if (obj! = null) {// Mandatory converts Object to IchildFormbase f = (ichildformBase) Obj; int v = f.Open ("test"); MessageBox .Show (v.toString ());}}