这是对上一个问题的跟进。我正在尝试将一些 Vb.net 代码转换为 C#。创建一个 com 对象 (atlDirectorObject.atlDirector) 并用于通过参数创建另一个 com 对象 (atl3270Tool)。atl3270Tool 未在 C# 版本中创建。尝试通过对象数组引用 atl3270Tool 是否走错了路?
'working vb code
Dim atl3270Tool
Dim ErrMsg As String
Dim atlDirectorObject = CreateObject("atlDirectorObject.atlDirector")
atlDirectorObject.CreateTool("3270", 1, True, True, 0, atl3270Tool, ErrMsg)
'atl3270Tool is working com object at this point = success
//non-working c# code
object atl3270Tool = null;
string ErrMsg = null;
object atlDirectorObject = Activator.CreateInstance(Type.GetTypeFromProgID("atlDirectorObject.atlDirector"));
//atlDirectorObject is a com object now
//attempt to reference atl3270Tool inside an object array
object[] p = { "3270", 1, true, true, 0, atl3270Tool, ErrMsg };
Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateCall(atlDirectorObject, null, "CreateTool", p, null, null, null, false);
//>>>>>>>>atl3270Tool is still null at this point<<<<<<<<<