Groups | Blog | Home
all groups > dotnet interop > february 2006 >

dotnet interop : Problem getting IDispatch iface for .NET objects from unmanaged co


Michael Goffioul
2/10/2006 5:43:25 AM
Hi,

I'm trying to access and manipulate .NET objects from unmanaged code using
COM. Up to now I succeeded in creating a ICorRuntimeHost object, getting the
default AppDomain and creating some .NET objects (I'm mainly interested in
System.Windows.Forms objects). The problem I have is twofold:

1) the IDispatch interface returns an error when looking for some properties
on some objects: typical example "ClientSize" in "System.Windows.Forms.Form"

2) I can't get access to an IDispatch interface for some specific classes,
in that case, most operations I try to perform on the .NET object return
COR_E_INVALIDOPERATION: typical example "System.Windows.Forms.ColorDialog"

Could anybody give me some hints on what's going on? Thanks.

Michael Goffioul
2/13/2006 2:03:29 PM
[quoted text, click to view]

I must add that the problem occurs only in .NET 2 (2.0.50727). Under .NET
1.1, I can
make it work. As System.Windows.Forms objects cannot be queried for
IDispatch interface,
I query _Object interface, which emulates IDispatch. Then I can create and
manipulate objects
like ColorDialog. However, this does not work anymore under .NET 2.

Michael.

AddThis Social Bookmark Button