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 / CLR / January 2007

Tip: Looking for answers? Try searching our database.

Interop gurus: Is it possible to determine the type of an unknown COM object?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Philip Daniels - 20 Jan 2007 17:11 GMT
I am doing some work with a client API via COM interop. I have
reached the situation where after this call to their API:

 object someObj = con.Peek(1);

"someObj" contains some type of COM object (shows type as
System.__COMObject).

I have no idea what someObj is, but it is likely to be some sort of
wrapper around an image : con.Peek(1) is ultimately retrieving a
bitmap from an IMAGE column in SQL server. I really can't be sure
though. I've tried casting someObj to all the types they expose in
their library and it fails on each one. (It's MBS Dynamics AX in case
you're interested).

Is it possible to figure out what someObj is and get the image data
out? Something using interop or reflection perhaps.

Any help much appreciated at this stage....

--
Philip Daniels
Ollie Riches - 22 Jan 2007 18:20 GMT
a bit rusty but here goes,

You could look up the interface using something like 'oleview.exe' - this
interogrates the registry and displays information about COM components.

If you want to do this programmatically - All COM interfaces derive from
IUknown and possibly IDispatch, If you query interface for the IDispatch
interface and recieve a valid interface back then you can use the
'GetTypeInfo' method to the info you want - this is only possible if the COM
object has support for OLE Automation (IDispatch). You will of course have
to add the IDispatch definition to yuor interop code.

HTH

Ollie Riches

>I am doing some work with a client API via COM interop. I have
> reached the situation where after this call to their API:
[quoted text clipped - 18 lines]
> --
> Philip Daniels
me@foo.com - 22 Jan 2007 23:27 GMT
>a bit rusty but here goes,
>
>You could look up the interface using something like 'oleview.exe' - this
>interogrates the registry and displays information about COM components.

Ok I found that tool. It looks like .Net has imported everything
exposed in the DLL perfectly.

>If you want to do this programmatically - All COM interfaces derive from
>IUknown and possibly IDispatch, If you query interface for the IDispatch
>interface and recieve a valid interface back then you can use the

Ollie, an example would really help...this works, but where do I go
from here?

IntPtr idesp = Marshal.GetIDispatchForObject(someObj);      

>'GetTypeInfo' method to the info you want - this is only possible if the COM
>object has support for OLE Automation (IDispatch). You will of course have
[quoted text clipped - 26 lines]
>> --
>> Philip Daniels

--
Philip Daniels

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.