R
Robert May
We have a VB6 COM component that I don't have control over. All of the
values are returned from method calls using byref parameters. They
frequently break binary compatibility, in fact, there are three different
versions of the component, one for dev, one for test, and one for
production, all of which are broken with each re-compile, which means I
can't use early binding and COM interop. Ugh.
Using InvokeMember, how do I get values from an out parameter? I saw the
documentation about ParameterModifier, but I'm afraid that I just don't get
it. A code sample would be appreciated.
Here's the code I have so far (the Response.Write value returns an empty
string as the return value, which isn't valid):
Type commonLogonType=
Type.GetTypeFromProgID("ADESecurity.CSecurity");
object commonLogon=
Activator.CreateInstance(commonLogonType);
arrayInput = new Object[] {""};
commonLogonType.InvokeMember("GetUserRightsAsXML",BindingFlags.InvokeMethod,
null,commonLogon,arrayInput,mods,null,null);
Response.Write("Returned XML value=" +
Convert.ToString(arrayInput[arrayInput.GetLowerBound(0)]));
Response.End();
}
Here's the VB method call (the return value is a 0 or non-zero value
indicating success or failure of the call, r_szXMLResult is the actual value
that is returned):
Public Function GetUserRightsAsXML(ByRef r_szXMLResult As Variant, _
Optional ByVal p_szXMLRootName As Variant
= "adesecuritypermissions", _
Optional ByVal p_lEntityID As Variant =
0, _
Optional ByVal p_bDebugDisplay As Boolean
= False _
) As Variant
Any help would be greatly appreciated.
Robert
values are returned from method calls using byref parameters. They
frequently break binary compatibility, in fact, there are three different
versions of the component, one for dev, one for test, and one for
production, all of which are broken with each re-compile, which means I
can't use early binding and COM interop. Ugh.
Using InvokeMember, how do I get values from an out parameter? I saw the
documentation about ParameterModifier, but I'm afraid that I just don't get
it. A code sample would be appreciated.
Here's the code I have so far (the Response.Write value returns an empty
string as the return value, which isn't valid):
Type commonLogonType=
Type.GetTypeFromProgID("ADESecurity.CSecurity");
object commonLogon=
Activator.CreateInstance(commonLogonType);
arrayInput = new Object[] {""};
commonLogonType.InvokeMember("GetUserRightsAsXML",BindingFlags.InvokeMethod,
null,commonLogon,arrayInput,mods,null,null);
Response.Write("Returned XML value=" +
Convert.ToString(arrayInput[arrayInput.GetLowerBound(0)]));
Response.End();
}
Here's the VB method call (the return value is a 0 or non-zero value
indicating success or failure of the call, r_szXMLResult is the actual value
that is returned):
Public Function GetUserRightsAsXML(ByRef r_szXMLResult As Variant, _
Optional ByVal p_szXMLRootName As Variant
= "adesecuritypermissions", _
Optional ByVal p_lEntityID As Variant =
0, _
Optional ByVal p_bDebugDisplay As Boolean
= False _
) As Variant
Any help would be greatly appreciated.
Robert