1.如果com是由.net实现
则在用自定义互操作集时,会发生类型转换错误。如下:
[ComImport]
[Guid("06521B83-FDE4-4882-9E29-3812D6A59AA8")]
class NetComponentWraper
{
}
[ComImport]
[CoClass(typeof(NetComponentWraper))]
[Guid("038AFEB5-A5B9-4944-8B3F-BA031A12797A")]
public interface IWelcomeWraper
{
//[DispId(60040)]
string Greeting(string name);
}
class Program
{
static void Main(string[] args)
{
NetComponentWraper netComponent = new NetComponentWraper();
IWelcomeWraper welcome = netComponent as IWelcomeWraper;
welcome.Greeting("asdf");
}
}
2.另一个问题,如何添加COM事件?