Question

I know I should write this in Vb.net but for my own reasons I'm attempting late binding against a Com Object in C# .net framework 3.5. The error I'm getting is "DISP_E_BADCALLEE" and I'm only getting that based on when the copybacks I want are set to true. Am I dealing with a security issue? My research lead me to try dropping "[assembly: AllowPartiallyTrustedCallers()]" in the AssemblyInfo file but that didn't do the trick. I dropped some details in a condensed version of the code below. It's failing on the 4th step. I'd appreciate your help. Thanks.

                //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]);
Was it helpful?

Solution

ScreenText should be set to null, not string.empty

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top