Hi,
I'm trying to access a COM object that only supports late binding.
This is how it works using VB6:
'Create an S_PLUS application object
Dim pApp As Object
Set pApp = CreateObject("SPLUS.Application");
Dim v1 As Variant, v2 As Variant
v1 = CVar("3D")
v2 = CVar("3D Line Plot")
bSuccess = pApp.ChooseGraphAndPlotType(v1, v2, hWnd)
'ChooseGraphAndPlotType() returns true if the user clicks the OK button
'If so, we print out the modified values of v1 and v2 which are the
'actual selections in the graph gallery.
This is what I have tried:
Type appType = Type.GetTypeFromProgID("SPLUS.Application");
object appObject = Activator.CreateInstance(appType);
object[] myArguments = new Object[3];
myArguments[0] = new StringBuilder("3D");
myArguments[1] = new StringBuilder("3D Line Plot");
myArguments[2] = this.Handle;
ParameterModifier pm = new ParameterModifier(3);
pm[0] = true;
pm[1] = true;
pm[2] = false;
ParameterModifier[] pmods = { pm };
object myBool = appType.InvokeMember("ChooseGraphAndPlotType",
BindingFlags.InvokeMethod, null, appObject, myArguments,
pmods, null, null);
When I run it I get
System.Runtime.InteropServices.COMException(0x800200005): Type mismatch.
I have tried using plain strings as myArguments with the same (Type
mismatch) result.
I would appreciate any help.
Jacek.
Jacek Krolikowski - 11 Jun 2004 12:25 GMT
Hi,
I am realy desperate here. Any help?
Jacek.
> Hi,
>
[quoted text clipped - 38 lines]
>
> Jacek.
Robert Jordan - 12 Jun 2004 18:30 GMT
> This is what I have tried:
>
[quoted text clipped - 3 lines]
> myArguments[0] = new StringBuilder("3D");
> myArguments[1] = new StringBuilder("3D Line Plot");
StringBuilder is probably wrong. Try string instead:
string s1 = "3D";
string s2 = "3D Line Plot";
myArguments[0] = s1;
myArguments[1] = s2;
> myArguments[2] = this.Handle;
> ParameterModifier pm = new ParameterModifier(3);
> pm[0] = true;
> pm[1] = true;
> pm[2] = false;
are the first 2 parameters really by ref?
regards
rob
Jacek Krolikowski - 13 Jun 2004 20:25 GMT
Thanks Rob,
Strings do not work though. The problem is that in the original VB6
function the same arguments are used to pass string values in and out of
the function. Thus my attempt with StringBuilder but it also does not
work.
Any other ideas. I begin to think that this is one of the things that
cannot be done but for some reason nobody whants to admit that.
Jacek.
> > This is what I have tried:
> >
[quoted text clipped - 21 lines]
> regards
> rob