1

我知道我应该在 Vb.net 中编写此代码,但出于我自己的原因,我正在尝试对 C# .net 框架 3.5 中的 Com 对象进行后期绑定。我得到的错误是“DISP_E_BADCALLEE”,我只是根据我想要的复制设置为 true 来得到它。我在处理安全问题吗?我的研究使我尝试在 AssemblyInfo 文件中删除“[assembly: AllowPartiallyTrustedCallers()]”,但这并没有成功。我在下面的代码的精简版本中删除了一些细节。它在第四步失败了。我会很感激你的帮助。谢谢。

                //step 1
        _atlDirectorObject = Activator.CreateInstance(Type.GetTypeFromProgID("atlDirectorObject.atlDirector"));
        //step 2
        object[] parms = { "3270", 1, true, true, 0, _atl3270Tool, _ErrMsg };
        Boolean[] CopyBack2 = new Boolean[7];
        CopyBack2[5] = true;  //atl3270Tool
        CopyBack2[6] = true;  //ErrMsg

        Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateCall(_atlDirectorObject, _atlDirectorObject.GetType(), "CreateTool", parms, null, null, CopyBack2, false);
        _atl3270Tool = parms[5];


        //step 3
        // now using _atl3270Tool we navigate mainframe screens
        object[] parms3 = { Screen, SubScreen, _Number, _ErrMsg };
        Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateCall(_atl3270Tool, _atl3270Tool.GetType(), "ShowScreen", parms3, null, null, null, false);

        //>>>>>>>>>>>>>>CODE FAILS ON THIS STEP<<<<<<<<<<<<
        //step 4
        Boolean[] CopyBack4 = new Boolean[5];
        CopyBack4[3] = true; //screentext
        CopyBack4[4] = true; //_errmsg
        object ScreenText = String.Empty;
        object[] parms4 = { Row, Col, Length, ScreenText, _ErrMsg};
        Microsoft.VisualBasic.CompilerServices.NewLateBinding.LateCall(_atl3270Tool, _atl3270Tool.GetType(), "ReadScreen", parms4, null, null, CopyBack4, false)

        // if it were working the code would read screen data into parms4[3] object
        // If CopyBack4[3 and/or 4] are set to true = error 
        // Is just CopyBack4[0,1,2] are true = no error but no result           
        //Errors out with "Invalid callee. (Exception from HRESULT: 0x80020010 (DISP_E_BADCALLEE))"


        return Convert.ToString(parms4[3]);
4

1 回答 1

0

ScreenText 应设置为 null,而不是 string.empty

于 2012-06-15T22:06:29.757 回答