首页 > 代码库 > 创建C#DLL

创建C#DLL

1. 创建classlibrary

2.编写一个COM接口和一个COM类

  [Guid("DBE0E8C4-1C61-41f3-B6A4-4E2F353D3D05")]        

public interface IManagedInterface       

  {             int PrintHi(string name);         }

  

      [Guid("C6659361-1625-4746-931C-36014B146679")]        

public class InterfaceImplementation : IManagedInterface    

     {             public int PrintHi(string name)             {                 Console.WriteLine("Hello, {0}!", name);                 return 33;             }         }

 

3.在PROJECT上点击右键,选择属性---》bulid,选择registry from com interep.

 

4.一定要以管理员的方式运行 VS

 

5.在BIN里面有dll。可以不用 CSC 那种命令行了,happy.