1

Topic: CComDispatchDriver putproperty for C# a class

Hello. I write COM library on C# WinForms on analog already existing on with ++ ATL. The problem description: Class Class1 on C# implements interface IClass which was used for the same class in with ++ to library. The application code on with ++ which uses these libraries, tries to receive/write down some properties Class1 (BackColor, ForeColor, Font, etc.) As follows: 1. Receives IDispatch* dispatch for Class1 2. Causes CComDispatchDriver::GetPropertyPutProperty with correct dispatch id for received above dispatch. For with ++ libraries all perfectly works, for  - the error method not found is returned. For  a class all dispatch id are put down in interface IClass (by call GetIDsOfNames it is received correct value) as tried to write them over everyone  in a class in a type  [DispId (-501)] - does not help. The direct method call at IDispatch* dispatch for Class1 works. The Dotnetovsky class is inherited at Control, tried to be inherited from UserControl - does not help. I ask from experts of the help that does not suffice at  a class and how to make, that calls CComDispatchDriver:: PutProperty for it earned. In advance thanks.

2

Re: CComDispatchDriver putproperty for C# a class

Hello, Sarevok, you wrote: S> I write COM library on C# WinForms on analog already existing on with ++ ATL. S> the problem Description: S> Class Class1 on C# implements interface IClass which was used for the same class in with ++ to library. The application code on with ++ which uses these libraries, tries to receive/write down some properties Class1 (BackColor, ForeColor, Font, etc.) As follows: S> 1. Receives IDispatch* dispatch for Class1 S> 2. Causes CComDispatchDriver::GetPropertyPutProperty with correct dispatch id for received above dispatch. S> For with ++ libraries all perfectly works, for  - the error method not found is returned. S> For  a class all dispatch id are put down in interface IClass (by call GetIDsOfNames it is received correct value) as tried to write them over everyone  in a class in a type  [DispId (-501)] - does not help. S> the direct method call at IDispatch* dispatch for Class1 works. S> the Dotnetovsky class is inherited at Control, tried to be inherited from UserControl - does not help. S> I ask from experts of the help that does not suffice at  a class and how to make, that calls CComDispatchDriver:: PutProperty for it earned. Probably, the description on With ++ and on # the interface are various. Here also result them here (enough general description and an interesting method/property). And as the Direct method call at IDispatch* dispatch for Class1 "is implemented".

3

Re: CComDispatchDriver putproperty for C# a class

Hello, Sarevok, you wrote: in AssemblyInfo.cs which in folder Properties Install ComVisible (true)]//Parameter ComVisible with value FALSE does types in the assembly invisible//for COM components. If it is required to address to type in this assembly through//COM, set to attribute ComVisible value TRUE for this type. [assembly: ComVisible (true)]

4

Re: CComDispatchDriver putproperty for C# a class

Hello, Vi2, you wrote: Vi2> Hello, Sarevok, you wrote:... Vi2> it is visible, the description on With ++ and on # the interface are various. Here also result them here (enough general description and an interesting method/property). And as the Direct method call at IDispatch* dispatch for Class1 "is implemented". Interfaces are identical, I used  the interface for creation of library and classes on c#: added  library in  the project, made using and  this interface in the class: Here is how it looks in : [Guid ("2E0D1A01-B540-11D1-A3DA-FC2B04C10000")] [TypeLibType (TypeLibTypeFlags. FDual | TypeLibTypeFlags. FDispatchable)] public interface IGraph2d {[ComAliasName ("stdole. OLE_COLOR")] [DispId (-501)] uint BackColor {get; set;} [ComAliasName ("stdole. OLE_COLOR")] [DispId (-513)] uint ForeColor {get; set;}...} Here the same interface from pluses: EXTERN_C const IID IID_IGraph2d; MIDL_INTERFACE ("2E0D1A01-B540-11D1-A3DA-FC2B04C10000") IGraph2d: public IDispatch {public:... virtual/* [helpstring] [id] [propget] */HRESULT STDMETHODCALLTYPE get_BackColor (/* [retval] [out] */OLE_COLOR *pVal) = 0; virtual/* [helpstring] [id] [propput] */HRESULT STDMETHODCALLTYPE put_BackColor (/* [in] */OLE_COLOR newVal) = 0; virtual/* [helpstring] [id] [propget] */HRESULT STDMETHODCALLTYPE get_ForeColor (/* [retval] [out] */OLE_COLOR *pVal) = 0; virtual/* [helpstring] [id] [propput] */HRESULT STDMETHODCALLTYPE put_ForeColor (/* [in] */OLE_COLOR newVal) = 0;} And so the card in  a class is described: BEGIN_COM_MAP (CGraph2d) COM_INTERFACE_ENTRY (IGraph2d) COM_INTERFACE_ENTRY2 (IDispatch, IGraph2d)... So the card of properties in  a class is described: BEGIN_PROP_MAP (CGraph2d) PROP_ENTRY_TYPE ("ForeColor", DISPID_FORECOLOR, CLSID_Graph2dProp, VT_UI4) PROP_ENTRY_TYPE ("BackColor", DISPID_BACKCOLOR, CLSID_Graph2dProp, VT_UI4)... You asked as the Direct method call at IDispatch* dispatch for Class1 "is implemented" It is my error, at IDispatch certainly there are only methods. The call works for object CComQIPtr <IGraph2d> pGraph2d; to which appropriated pDispatch. For example VERIFY (pGraph2d-> put_BackColor (m_BackColor) == S_OK); I feel that matter is not in  the code, something does not suffice in  a class, whether implementation of any interface (IPropertyNotifySinkCP, CStockPropImpl, IConnectionPointContainerImpl.?) that still that. But I do not understand while I Will be glad to any help. In advance thanks.

5

Re: CComDispatchDriver putproperty for C# a class

Hello, Sarevok, you wrote: S> Interfaces are identical, I used  the interface for creation of library and classes on c#: added  library in  the project, made using and  this interface in the class: S> Here is how it looks in : S> [Guid ("2E0D1A01-B540-11D1-A3DA-FC2B04C10000")] S> [TypeLibType (TypeLibTypeFlags. FDual | TypeLibTypeFlags. FDispatchable)] S> public interface IGraph2d S> {S> [ComAliasName ("stdole. OLE_COLOR")] S> [DispId (-501)] S> uint BackColor {get; set;} S> [ComAliasName ("stdole. OLE_COLOR")] S> [DispId (-513)] S> uint ForeColor {get; set;} S>... S>} To tell the truth, I do not represent, as it looks in language IDL (I will try to simulate on one our project, but it will be at a distant day). I can while only to formulate a problem: in the CATFISH there are 4 methods/properties with the same name (same DISPID): a method, property-get, property-put and property-putref. These methods are not interchangeable, i.e. at explicit request is satisfied requested (with one exception - at request simultaneously a method or property-get, i.e. DISPATCH_METHOD|DISPATCH_PROPERTYGET, it is returned either a method, or property-get that is in object. There is convergence that it is possible to use DISPATCH_PROPERTYPUT|DISPATCH_PROPERTYPUTREF, but I did not meet with such). Therefore it is necessary to check up presence of a required method in TLB (IDL). Also there is output agent IDispatch who also imports the contribution at obtaining of the incorrect data on an input. Sometimes too it is returned, in particular, for example, Invoke returns DISP_E_MEMBERNOTFOUND if one of the following conditions occurs: - A member or parameter with the specified DISPID and matching cArgs cannot be found, and the parameter is not optional. S> I feel that matter is not in  the code, something does not suffice in  a class, whether implementation of any interface (IPropertyNotifySinkCP, CStockPropImpl, IConnectionPointContainerImpl.?) that still that. But I do not understand while I Will be glad to any help. But only not additional interfaces. Probably, something needs to be described still in IGraph2d.