Asp call the. net dll file Method

Source: Internet
Author: User

If you need to call the. net dll file method in asp, refer.

1. Create a new Class project in. net Visual Studio.

2. Add a new class in the project. The Code is as follows:

The Code is as follows: Copy code

Using System;
Namespace ClassLibrary1
{
// Define the interface, which is very important (the methods in this interface are the same as those in the COM component)
Public interface iClass1
{
String test ();
}

Public class Class1: iClass1
{
Private string t = "";
// Method in the implementation Interface
Public string test ()
{
Return "OK ";
}
}
}

3. Modify the ComVisible attribute of AssemblyInfo. cs under the Properties directory to True.


4. Choose "project menu"> "MyLib property", find the "generate" tab, and click "register for COM Interop ".




5. Continue, find the "signature" tab, and click "sign for assembly". In the drop-down box below, select "<new...>"


6. In the pop-up dialog box, enter "MyLib" (whatever name) to remove the option of password-protected files.


7. Right-click the VS Command Prompt


8. Compile (generate)

Enter the directory where the Dll is located at the command prompt.

Use gacutil/I ClassLibrary1.dll to add this DLL to the global Cache

Then use regasm ClassLibrary1.dll to register this dll.


9. Test in asp
 

The Code is as follows: Copy code

<%
SET s = CreateObject ("ClassLibrary1.Class1 ")
Response. Write (s. test ())
%>

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.