C#调用VC写的OCX的问题,报“灾难性故障”
我用VC6的Active controlwizard 做了个很简单OCX,只有向一个变量num赋值的功能用测试容器和VC调用都可以
现在我在C#中把这个OCX引用进来,然后用下面方法调用
public partial class Form1 : Form
{
private TESTLib.Test TestOCX;
public Form1()
{
InitializeComponent();
try
{
TestOCX = new TESTLib.TestClass();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
private void button1_Click(object sender, EventArgs e)
{
try
{
TestOCX.num = 33;
}
catch (Exception ex)
{
Console.WriteLine(ex.Message); //报错 {"灾难性故障 (Exception from HRESULT: 0x8000FFFF (E_UNEXPECTED))"}
}
}
}
//在执行TestOCX = new TESTLib.TestClass(); 后查看num已经有了错误 num = '((TEST6Lib.Test6Class)(TestOCX)).num' threw an exception of type 'System.Runtime.InteropServices.COMException'
请问应该怎么调用,请教,谢谢! --------------------编程问答-------------------- up --------------------编程问答-------------------- jf --------------------编程问答-------------------- 控件没有容器。参考
Windows Forms ActiveX Control Importer (Aximp.exe) --------------------编程问答-------------------- MARK --------------------编程问答-------------------- MARK
补充:.NET技术 , C#