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 ()) %> |