using System; using System.Collections.Generic;
using System.Linq; using System.Text;
using System.Runtime.InteropServices;
namespace TestCom
{ [Guid("E9BCF867-CD81-40d0-9591-ED28D1ED2B53")]
public interface IEncrypt
{ [DispId(1)]
string GetEncrypt(string str,string str2);
}
[Guid("33A6E58D-E1F5-4b53-B2E2-03B9F8BA2FAD"),
ClassInterface(ClassInterfaceType.None)]
public class Encrypt:IEncrypt
{ public Encrypt(){}
public string GetEncrypt(string str,string str2)
{
return "测试 | "+str+"|"+str2;
}
}
}
打开 Project--> Properties菜单 在Application标签中打开 Assembly Information 将Make assembly Com-Visible一项选中。再切换到Build标签将 Register for COM interop一项选中。
Guid的生成:打开Visual Studio Command Prompt 输入guidgen 命令调出工具。类型选择Registry Format,点击New Guid,然后COPY出来。