Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Interop / June 2004

Tip: Looking for answers? Try searching our database.

Passing strings back from COM server when using late binding

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jacek Krolikowski - 10 Jun 2004 13:21 GMT
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

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.