C # dynamically call the delegate DLL

Source: Internet
Author: User

Main Code of the called TestDll. dll file:

Using System;

Using System. Collections. Generic;

Using System. Text;

Namespace TestDll

{

Public class TestDll

{

Public string HandleStr (string str)

{

Return "[" + str + "]";

}

}

}

Code for calling the HandleStr method of TestDll. dll:

Using System;

Using System. Collections. Generic;

Using System. ComponentModel;

Using System. Data;

Using System. Drawing;

Using System. Text;

Using System. Windows. Forms;

Using System. Reflection;

 

Namespace DynamicInvokeDll

{

Public partial class FrmMain: Form

{

Public FrmMain ()

{

InitializeComponent ();

}

 

Private void FrmMain_Load (object sender, EventArgs e)

{

Object [] obj = new object [1];

Obj [0] = "DllInvoke ";

Object o2 = DllInvoke ("TestDll. dll", "TestDll", "TestDll", "HandleStr", obj );

MessageBox. Show (o2.ToString ());

}

 

/// <Summary>

/// Call DLL dynamically

/// </Summary>

/// <Param name = "DllFileName"> dll name </param>

/// <Param name = "NameSpace"> NameSpace </param>

&

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.