HighTechTalks DotNet Forums  

Re: What is DispId used for?

Dotnet Framework (Interop) microsoft.public.dotnet.framework.interop


Discuss Re: What is DispId used for? in the Dotnet Framework (Interop) forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
DeveloperX
 
Posts: n/a

Default Re: What is DispId used for? - 08-17-2007 , 05:16 AM






On 16 Aug, 19:22, Daniel Lidström <some... (AT) microsoft (DOT) com> wrote:
Quote:
Hello!

I've read on MSDN [1] that it is necessary to mark methods and properties
with DispId in order to expose them to COM. But that doesn't seem
necessary. I've created interfaces and subclasses in C# and I have no
problem using them from C++. So what is DispId really used for?

[1] Example COM Class (C#):http://msdn2.microsoft.com/en-us/lib...20(VS.80).aspx

--
Daniel
the dispid is used with IDispatch which allows COM to late bind. COM
also has the IUnknown interface which is used for early binding.
(disclaimer, I think )



Reply With Quote
  #2  
Old   
Micky Duncan
 
Posts: n/a

Default Re: What is DispId used for? - 09-05-2007 , 08:25 PM






IUnknown has nothing to do with early binding. Both early and late binding
involve IDispatch and are used by automation clients. Early binding is used
by say VB which has access to a type library at compile time. VB with early
binding knows about strong types and can create objects such as

dim widget as new MickysMyLib.Widget

VB inspects the type library and determines the progids/dispids and invokes
methods by progid which is faster than late binding. Automation clients
will cache the progids so that they do not need to perform a lookup again.
Some clients are quite powerful and will actually invoke methods by using
the vtable on dual interfaces in the same way as c++ apps will - this is
extremely fast.

Late binding is used by say VB Script which cannot use type libraries to
create rich types. it creates objects with calls like

set widget = CreateObject ("Micky.MyLib.Widget")

calling any methods are very slow compared to early binding since lookups
are required.

IUnknown is NOT accessible from your VB or VB Script code.

--
Cheers,
Micky D
"DeveloperX" <nntpDev (AT) operamail (DOT) com> wrote

On 16 Aug, 19:22, Daniel Lidström <some... (AT) microsoft (DOT) com> wrote:
Quote:
Hello!

I've read on MSDN [1] that it is necessary to mark methods and properties
with DispId in order to expose them to COM. But that doesn't seem
necessary. I've created interfaces and subclasses in C# and I have no
problem using them from C++. So what is DispId really used for?

[1] Example COM Class
(C#):http://msdn2.microsoft.com/en-us/lib...20(VS.80).aspx

--
Daniel
the dispid is used with IDispatch which allows COM to late bind. COM
also has the IUnknown interface which is used for early binding.
(disclaimer, I think )



Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.