Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the ASP calling method of COM component in C #

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/02 Report--

This article mainly introduces "what is the ASP calling method of the COM component in C#". In the daily operation, I believe that many people have doubts about the ASP calling method of the COM component in C#. The editor consulted all kinds of materials and sorted out the simple and easy-to-use operation method. I hope it will be helpful to answer the doubt of "what is the ASP calling method of the COM component in C#"! Next, please follow the editor to study!

1 create a new class library MyTestDLL

2 right-click the project "MyTestDLL"-"Properties -" generate-"check" to register for COM interoperability "

3 Open AssemblyInfo.cs file and modify [assembly: ComVisible (true)]

4 Open the command prompt line tool for Visual Sutdio 2008, enter guidgen.exe, select DEFINE_GUID, click "New GUID"

5 code

1. Each class name corresponds to an interface name, which is preceded by an uppercase I

2. The method declared in the interface uses the attribute [DispId (n)]

3. The class must have a no-parameter constructor

Code using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Runtime.InteropServices; namespace MyTestDll {/ / here Guid is generated for step 4. [Guid ("FFA4B191-FB5B-4dd5-B7B1-B2F32BF6F1FF")] public interface IMyTestDll {[DispId (0)] string GetAbout ();} public class Test1:IMyTestDll {private string summary; public Test1 () {summary = "this is my * test" } public string GetAbout () {return summary;}

6 build the project

ASP test code

Tip: if you want to use our C # COM component on other computers, you also need to register with regasm.

The method is:

First copy the files from the bin\ Debug directory to the target computer, and then open the command prompt tool to enter:

Regasm the directory / file name you copied to. Dll/ tlb f:/dll/ file name. Tlb / codebase

The operation can be used on this computer.

At this point, the study on "what is the ASP calling method of COM components in C#" is over. I hope to be able to solve your doubts. The collocation of theory and practice can better help you learn, go and try it! If you want to continue to learn more related knowledge, please continue to follow the website, the editor will continue to work hard to bring you more practical articles!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report