1. Call the COM component:
Type type = type. gettypefromprogid ("visualphd. Data" );
Dynamic PHD = activator. createinstance (type );
PhD. hostname = "192.168.53.186 ";
2. Reflection call DOTNET class
Type type = type. GetType ("leleapplication1.test ");
Dynamic T = activator. createinstance (type );
T. Print ("Hello! ");
3. Using pinvoke is simpler
Download open source component http://code.google.com/p/dynamicdllimport/
You can use the following to call an unmanaged DLL, including a Windows API and a self-developed C-format DLL.
Dynamic USER32 = new dynamicdllimport ("user32.dll", callingconvention: callingconvention. winapi );
User32.messagebox (0, "Hello World", "platform invoke sample", 0 );
Dynamic asmproject = new dynamicdllimport ("asmproject. dll ");
Int value = asmproject. Add <int> (3, 4 );
Console. writeline (value );
Dynamic SDL = new dynamicdllimport ("SDL. dll", charset. ANSI );
SDL. sdl_rect rect = new SDL. sdl_rect (
0,
0,
(Short) width,
(Short) height );
Int result = SDL. sdl_fillrect <int> (rgbsurfaceptr, ref rect, 0 );
SDL. sdl_event EVT;
While (SDL. sdl_waitevent (Out EVT )! = 0)
{
If (EVT. type = SDL. sdl_quit)
{
Break;
}
}