1
我想下面的VB6代碼轉換成C#如何在C#中創建對象?
If optHost(0).Value Then
Set m_oScpiAccess = New IcSCPIActiveX.IcSCPIAccess
Else
sHost = txtHost.Text
Set m_oScpiAccess = CreateObject("Exfo.IcSCPIActiveX.IcSCPIAccess", sHost)
End If
我用TLBIMP.EXE以創建COM類包裝,和我想:
if (string.IsNullOrEmpty(host))
{
// this works
IcSCPIAccess = new IcSCPIAccess();
}
else
{
// throws MissingMethodException
IcSCPIAccess = (IcSCPIAccess)Activator.CreateInstance(
typeof(IcSCPIAccessClass),
host);
}
但沒有構造函數接受host
參數
我不知道答案,但可以指出你的.NET/COM互操作性聖經Adam Nathan的「.Net和COM:完整的互操作性指南」 – pm100 2012-08-06 23:33:08