Discussion:
Implementing IDispatch in C#
(too old to reply)
Juan Dent
2004-09-18 23:21:03 UTC
Permalink
Hi,

Yes, it sounds strange. Yet, I am doing a migration of some code in C++
using COM to C# in .NET and this C++ unmanaged code calls the IDispatch
methods GetIDsOfNames and Invoke which have a special implementation in the
original C++ COM servers. All the logic of these COM servers depends on their
particular implementation of IDispatch.

One idea I have is that the new .NET implementations expose interfaces as
Dual, so perharps I could just expose them as IUnknown and add the IDispatch
members by hand. Is this ok?
--
Thanks in advance,

Juan Dent, M.Sc.
Peter Huang
2004-09-20 09:09:59 UTC
Permalink
Hi,

I think you may try to implment the IDispatch interface in C#.
Here is a link about implement IDocHostUIHandler.
Using MSHTML Advanced Hosting Interfaces
http://www.codeproject.com/csharp/advhost.asp

Here is a link about the IDispatch definition in C#.
http://www.error-bank.com/microsoft.public.dotnet.languages.csharp/240929_Th
read.aspx

You may have a try and let me know the result.

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
Peter Huang
2004-09-22 03:46:13 UTC
Permalink
Hi,

I think we need to implement them all by ourself.
Actually in mfc, when compiler, the IDE will help to inject the
implementation code into our project so we do not do it ourselves.
Here is the MFC src path.
<install path>\VC98\MFC\SRC\OLEDISP1.CPP

Best regards,

Peter Huang
Microsoft Online Partner Support

Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
Juan Dent
2004-09-21 22:13:04 UTC
Permalink
Thanks. Yet, before trying anything, I need to be able to access the default
implementation of IDispatch since I only need to change its behavior in a
couple of places and let the default behavior work otherwise...

Any suggestion?
Post by Peter Huang
Hi,
I think you may try to implment the IDispatch interface in C#.
Here is a link about implement IDocHostUIHandler.
Using MSHTML Advanced Hosting Interfaces
http://www.codeproject.com/csharp/advhost.asp
Here is a link about the IDispatch definition in C#.
http://www.error-bank.com/microsoft.public.dotnet.languages.csharp/240929_Th
read.aspx
You may have a try and let me know the result.
Best regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
Continue reading on narkive:
Loading...