C#的COM编程问题,急~
C#如何开发COM程序,从网上找了很多资料,很少。仿照一片文章写了一个测试程序,结果调用不了。对COM了解甚少,请大侠指点。下面是我写的COM代码:
using System;
using System.Collections.Generic;
using System.Text;
using System.Runtime.InteropServices;
using System.IO;
using System.Net;
using System.Net.Sockets;
namespace SynchronousSocketClient
{
// 类 接 口
[Guid( "44475602-F2E1-49d3-8CA6-22BF6DF89835 ")]
public interface Client_Interface
{
[DispId(1)]
Boolean StartClient(string strIP, string strPort);
[DispId(2)]
Boolean SendByteData(byte[] sendData);
[DispId(3)]
Boolean ReceiveByteData(out byte[] sendData);
}
// 事件接口
[Guid( "47C976E0-C208-4740-AC42-41212D3C34F0 "),
InterfaceType(ComInterfaceType.InterfaceIsIDispatch)]
public interface Client_Events
{
}
// 接口实现
[Guid( "D0C200A0-5B4D-46b6-B2C0-748BE01F4691 "),
ClassInterface(ClassInterfaceType.None),
ComSourceInterfaces(typeof(Client_Events))]
public class SynchronousSocketClient : Client_Interface
{
private Socket remoteClient;
private string strServerIP;
private string strServerPort;
private const int recBufferCount = 2048;
public Boolean StartClient(string strIP, string strPort)
{
try
{
strServerIP = strIP;
strServerPort = strPort;
IPHostEntry ipHostInfo = Dns.Resolve(strServerIP);
IPAddress ipA