我有一个引用VB6 dll的C#应用程序。当我将null从C#传递到VB6 dll函数时,null会被翻译为VB6中的Empty值(value),而不是Nothing对象。例如:
// function in vb6 dll that referenced by c# app
Public Sub TestFunc(ByVal oValue As Variant)
{
...
if oValue is Nothing then
set oValue = someObject
end if
...
}
// main c# code
private void Form1_Load(object sender, EventArgs e)
{
object testObject = new object();
testObject = null;
TestFunc(testObject);
}
当我传递一个对象(非空)时,它将作为对象传递到VB6中。 但是当null传递到vb6时,它会变成值类型Empty,而不是对象类型Nothing。 有人知道为什么吗?是否有任何方法可以在从C#应用程序传递null时强制将其作为Nothing传递给VB6?非常感谢。