"Querying" interfaces

  • Thread starter Thread starter Chris
  • Start date Start date
C

Chris

Hi,
With COM, I was able to create an object supporting
various interfaces, and by overloading QueryInterface
to decide at runtime if the interface beeing queried was
actually available (given the current state of the object)
or not.
Is there such a possibility with managed .net classes
derived from several interfaces ? Is there some way to
make a dynamic_cast fail ?

Chris.
 
With COM, I was able to create an object supporting
various interfaces, and by overloading QueryInterface
to decide at runtime if the interface beeing queried was
actually available (given the current state of the object)
or not.

If you implemented such "dynamic" COM objects, you have violated following
rule of COM interfaces:

"The set of interfaces accessible on an object through
IUnknown::QueryInterface must be static, not dynamic. This means that if a
call to QueryInterface for a pointer to a specified interface succeeds the
first time, it must succeed again, and if it fails the first time, it must
fail on all subsequent queries."

(Platform SDK: COM, IUnknown::QueryInterface)
Is there such a possibility with managed .net classes
derived from several interfaces ? Is there some way to
make a dynamic_cast fail ?

To derive such dynamic behaviour, IServiceProvider interface is usually
implemented.

P.S.: COM also has it's own IServiceProvider interface.
 
Hello Chris,

I was reviewing the issue thread. Do you have any more concern on
Vladimir's answer? If there is any we can do, please feel free to post
here.

Thanks very much.

Best regards,
Yanhong Huang
Microsoft Community Support

Get Secure! ¨C www.microsoft.com/security
Register to Access MSDN Managed Newsgroups!
-http://support.microsoft.com/default.aspx?scid=/servicedesks/msdn/nospam.as
p&SD=msdn

This posting is provided "AS IS" with no warranties, and confers no rights.
 
Back
Top