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 / September 2004

Tip: Looking for answers? Try searching our database.

Easier way to get the default property?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Chad Myers - 23 Sep 2004 22:15 GMT
I have a .NET class that's COMVisible(true) and it has a method
that takes an object (VARIANT*) argument.

I'm running into a problem where an ASP/JScript client is
passing a Request.QueryString("foo") result into this argument.

Request.QueryString("foo") returns an IStringList which is not
marshable in .NET by default.

I have to assume that users could pass in any type of data
into my method, so if .NET couldn't marshal it and gives me a
System.__ComObject, then I do all the IDispatch stuff to invoke
the default property (DISPID 0).

Is there an easier (read: built in) way of getting the default
property from a __ComObject?

Thanks,
Chad
Robert Jordan - 23 Sep 2004 23:34 GMT
> I have a .NET class that's COMVisible(true) and it has a method
> that takes an object (VARIANT*) argument.
[quoted text clipped - 12 lines]
> Is there an easier (read: built in) way of getting the default
> property from a __ComObject?

Via reflection (which in turn uses IDispatch):

comObject.GetType().InvokeMember(
    "", // -> default member
    BindingFlags.InvokeMethod,
    null,
    comObject,
    null
    );

bye
Rob
Chad Myers - 24 Sep 2004 00:01 GMT
> > <snip>
> >
[quoted text clipped - 10 lines]
>      null
>      );

So much simpler! Thank you for the quick reply.

Works like a champ.

Thanks again,
Chad

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.