Hi All,
I'm trying to generate a C# wrapper for a Windows type library using the following command line ...
csc /target:library /doc:Interop.MyL ibrary.xml /unsafe Interop.MyLibra ry.cs >Interop.MyLibr ary.log
And receiving the following error message ...
Interop.MyLibra ry.cs(499,18): error CS0536: 'Interop.MyLibr ary.IImpBaseCol lection_SinkHel per' does not implement interface member 'Interop.MyLibr ary.IImpBaseCol lection.Item(ob ject)'. 'Interop.MyLibr ary.IImpBaseCol lection_SinkHel per.Item(object )' is either static, not public, or has the wrong return type.
Here's the code....
The line where the error occurs is in Bold Blue
Any ideas appreciated!! ;-)
Thanks,
Roland
-----------------
/// <summary><para> <c>IImpBaseColl ection</c> interface.</para></summary>
[Guid("5616A320-AB4D-11D0-8E2F-00A0C9050603")]
[ComImport]
[TypeLibType((sh ort)4096)]
[DefaultMember(" Item")]
[InterfaceTypeAt tribute(ComInte rfaceType.Inter faceIsIDispatch )]
public interface IImpBaseCollect ion: System.Collecti ons.IEnumerable
{
/// <summary><para> <c>Item</c> method of <c>IImpBaseColl ection</c> interface.</para></summary>
/// <remarks><para> An original IDL definition of <c>Item</c> method was the following: <c>HRESULT Item (VARIANT nIndex, [out, retval] IDispatch** ReturnValue)</c>;</para></remarks>
// IDL: HRESULT Item (VARIANT nIndex, [out, retval] IDispatch** ReturnValue);
// VB6: Function Item (ByVal nIndex As Any) As IDispatch
[DispId(0)]
[return: MarshalAs(Unman agedType.IDispa tch)]
object Item (object nIndex);
/// <summary><para> <c>_NewEnum</c> property of <c>IImpBaseColl ection</c> interface.</para></summary>
/// <remarks><para> An original IDL definition of <c>_NewEnum</c> property was the following: <c>IUnknown* _NewEnum</c>;</para></remarks>
// IDL: IUnknown* _NewEnum;
// VB6: _NewEnum As IUnknown
object _NewEnum
{
// IDL: HRESULT _NewEnum ([out, retval] IUnknown** ReturnValue);
// VB6: Function _NewEnum As IUnknown
[DispId(-4)]
[return: MarshalAs(Unman agedType.IUnkno wn)]
get;
}
/// <summary><para> Parent property of IImpBaseCollect ion interface.</para></summary>
/// <remarks><para> An original IDL definition of <c>Parent</c> property was the following: <c>IDispatch* Parent</c>;</para></remarks>
// IDL: IDispatch* Parent;
// VB6: Property Parent As IDispatch
[DispId(2)]
object Parent
{
[return: MarshalAs(Unman agedType.IDispa tch)]
get;
}
/// <summary><para> Count property of IImpBaseCollect ion interface.</para></summary>
/// <remarks><para> An original IDL definition of <c>Count</c> property was the following: <c>long Count</c>;</para></remarks>
// IDL: long Count;
// VB6: Property Count As Long
[DispId(3)]
int Count
{
get;
}
}
/// <summary><para> Delegate for handling <c>Item</c> event of <c>IImpBaseColl ection</c> interface.</para></summary>
/// <remarks><para> An original IDL definition of <c>Item</c> event was the following: <c>HRESULT IImpBaseCollect ion_ItemEventHa ndler (VARIANT nIndex, [out, retval] IDispatch** ReturnValue)</c>;</para></remarks>
// IDL: HRESULT IImpBaseCollect ion_ItemEventHa ndler (VARIANT nIndex, [out, retval] IDispatch** ReturnValue);
// VB6: Function IImpBaseCollect ion_ItemEventHa ndler (ByVal nIndex As Any) As IDispatch
[return: MarshalAs(Unman agedType.IDispa tch)]
public delegate object IImpBaseCollect ion_ItemEventHa ndler (object nIndex);
/// <summary><para> Delegate for handling <c>_NewEnum</c> event of <c>IImpBaseColl ection</c> interface.</para></summary>
/// <remarks><para> An original IDL definition of <c>_NewEnum</c> event was the following: <c>HRESULT IImpBaseCollect ion__NewEnumEve ntHandler ([out, retval] IUnknown** ReturnValue)</c>;</para></remarks>
// IDL: HRESULT IImpBaseCollect ion__NewEnumEve ntHandler ([out, retval] IUnknown** ReturnValue);
// VB6: Function IImpBaseCollect ion__NewEnumEve ntHandler As IUnknown
[return: MarshalAs(Unman agedType.IUnkno wn)]
public delegate object IImpBaseCollect ion__NewEnumEve ntHandler () /* property get method */;
/// <summary><para> Declaration of events of <c>IImpBaseColl ection</c> source interface.</para></summary>
[ComEventInterfa ce(typeof(IImpB aseCollection), typeof(IImpBase Collection_Even tProvider))]
[ComVisible(fals e)]
public interface IImpBaseCollect ion_Event
{
/// <summary><para> <c>Item</c> event of <c>IImpBaseColl ection</c> interface.</para></summary>
event IImpBaseCollect ion_ItemEventHa ndler Item;
/// <summary><para> <c>_NewEnum</c> event of <c>IImpBaseColl ection</c> interface.</para></summary>
event IImpBaseCollect ion__NewEnumEve ntHandler _NewEnum;
}
[ClassInterface( ClassInterfaceT ype.None)]
internal class IImpBaseCollect ion_SinkHelper: IImpBaseCollect ion
{
public int Cookie = 0;
public event IImpBaseCollect ion_ItemEventHa ndler ItemDelegate = null;
public void Set_ItemDelegat e(IImpBaseColle ction_ItemEvent Handler deleg)
{
ItemDelegate = deleg;
}
public bool Is_ItemDelegate (IImpBaseCollec tion_ItemEventH andler deleg)
{
return (ItemDelegate == deleg);
}
public void Clear_ItemDeleg ate()
{
ItemDelegate = null;
}
void Item (object nIndex)
{
if (ItemDelegate!= null)
ItemDelegate(nI ndex);
}
public event IImpBaseCollect ion__NewEnumEve ntHandler _NewEnumDelegat e = null;
public void Set__NewEnumDel egate(IImpBaseC ollection__NewE numEventHandler deleg)
{
_NewEnumDelegat e = deleg;
}
public bool Is__NewEnumDele gate(IImpBaseCo llection__NewEn umEventHandler deleg)
{
return (_NewEnumDelega te == deleg);
}
public void Clear__NewEnumD elegate()
{
_NewEnumDelegat e = null;
}
void _NewEnum () /* property get method */
{
if (_NewEnumDelega te!=null)
_NewEnumDelegat e();
}
}
I'm trying to generate a C# wrapper for a Windows type library using the following command line ...
csc /target:library /doc:Interop.MyL ibrary.xml /unsafe Interop.MyLibra ry.cs >Interop.MyLibr ary.log
And receiving the following error message ...
Interop.MyLibra ry.cs(499,18): error CS0536: 'Interop.MyLibr ary.IImpBaseCol lection_SinkHel per' does not implement interface member 'Interop.MyLibr ary.IImpBaseCol lection.Item(ob ject)'. 'Interop.MyLibr ary.IImpBaseCol lection_SinkHel per.Item(object )' is either static, not public, or has the wrong return type.
Here's the code....
The line where the error occurs is in Bold Blue
Any ideas appreciated!! ;-)
Thanks,
Roland
-----------------
/// <summary><para> <c>IImpBaseColl ection</c> interface.</para></summary>
[Guid("5616A320-AB4D-11D0-8E2F-00A0C9050603")]
[ComImport]
[TypeLibType((sh ort)4096)]
[DefaultMember(" Item")]
[InterfaceTypeAt tribute(ComInte rfaceType.Inter faceIsIDispatch )]
public interface IImpBaseCollect ion: System.Collecti ons.IEnumerable
{
/// <summary><para> <c>Item</c> method of <c>IImpBaseColl ection</c> interface.</para></summary>
/// <remarks><para> An original IDL definition of <c>Item</c> method was the following: <c>HRESULT Item (VARIANT nIndex, [out, retval] IDispatch** ReturnValue)</c>;</para></remarks>
// IDL: HRESULT Item (VARIANT nIndex, [out, retval] IDispatch** ReturnValue);
// VB6: Function Item (ByVal nIndex As Any) As IDispatch
[DispId(0)]
[return: MarshalAs(Unman agedType.IDispa tch)]
object Item (object nIndex);
/// <summary><para> <c>_NewEnum</c> property of <c>IImpBaseColl ection</c> interface.</para></summary>
/// <remarks><para> An original IDL definition of <c>_NewEnum</c> property was the following: <c>IUnknown* _NewEnum</c>;</para></remarks>
// IDL: IUnknown* _NewEnum;
// VB6: _NewEnum As IUnknown
object _NewEnum
{
// IDL: HRESULT _NewEnum ([out, retval] IUnknown** ReturnValue);
// VB6: Function _NewEnum As IUnknown
[DispId(-4)]
[return: MarshalAs(Unman agedType.IUnkno wn)]
get;
}
/// <summary><para> Parent property of IImpBaseCollect ion interface.</para></summary>
/// <remarks><para> An original IDL definition of <c>Parent</c> property was the following: <c>IDispatch* Parent</c>;</para></remarks>
// IDL: IDispatch* Parent;
// VB6: Property Parent As IDispatch
[DispId(2)]
object Parent
{
[return: MarshalAs(Unman agedType.IDispa tch)]
get;
}
/// <summary><para> Count property of IImpBaseCollect ion interface.</para></summary>
/// <remarks><para> An original IDL definition of <c>Count</c> property was the following: <c>long Count</c>;</para></remarks>
// IDL: long Count;
// VB6: Property Count As Long
[DispId(3)]
int Count
{
get;
}
}
/// <summary><para> Delegate for handling <c>Item</c> event of <c>IImpBaseColl ection</c> interface.</para></summary>
/// <remarks><para> An original IDL definition of <c>Item</c> event was the following: <c>HRESULT IImpBaseCollect ion_ItemEventHa ndler (VARIANT nIndex, [out, retval] IDispatch** ReturnValue)</c>;</para></remarks>
// IDL: HRESULT IImpBaseCollect ion_ItemEventHa ndler (VARIANT nIndex, [out, retval] IDispatch** ReturnValue);
// VB6: Function IImpBaseCollect ion_ItemEventHa ndler (ByVal nIndex As Any) As IDispatch
[return: MarshalAs(Unman agedType.IDispa tch)]
public delegate object IImpBaseCollect ion_ItemEventHa ndler (object nIndex);
/// <summary><para> Delegate for handling <c>_NewEnum</c> event of <c>IImpBaseColl ection</c> interface.</para></summary>
/// <remarks><para> An original IDL definition of <c>_NewEnum</c> event was the following: <c>HRESULT IImpBaseCollect ion__NewEnumEve ntHandler ([out, retval] IUnknown** ReturnValue)</c>;</para></remarks>
// IDL: HRESULT IImpBaseCollect ion__NewEnumEve ntHandler ([out, retval] IUnknown** ReturnValue);
// VB6: Function IImpBaseCollect ion__NewEnumEve ntHandler As IUnknown
[return: MarshalAs(Unman agedType.IUnkno wn)]
public delegate object IImpBaseCollect ion__NewEnumEve ntHandler () /* property get method */;
/// <summary><para> Declaration of events of <c>IImpBaseColl ection</c> source interface.</para></summary>
[ComEventInterfa ce(typeof(IImpB aseCollection), typeof(IImpBase Collection_Even tProvider))]
[ComVisible(fals e)]
public interface IImpBaseCollect ion_Event
{
/// <summary><para> <c>Item</c> event of <c>IImpBaseColl ection</c> interface.</para></summary>
event IImpBaseCollect ion_ItemEventHa ndler Item;
/// <summary><para> <c>_NewEnum</c> event of <c>IImpBaseColl ection</c> interface.</para></summary>
event IImpBaseCollect ion__NewEnumEve ntHandler _NewEnum;
}
[ClassInterface( ClassInterfaceT ype.None)]
internal class IImpBaseCollect ion_SinkHelper: IImpBaseCollect ion
{
public int Cookie = 0;
public event IImpBaseCollect ion_ItemEventHa ndler ItemDelegate = null;
public void Set_ItemDelegat e(IImpBaseColle ction_ItemEvent Handler deleg)
{
ItemDelegate = deleg;
}
public bool Is_ItemDelegate (IImpBaseCollec tion_ItemEventH andler deleg)
{
return (ItemDelegate == deleg);
}
public void Clear_ItemDeleg ate()
{
ItemDelegate = null;
}
void Item (object nIndex)
{
if (ItemDelegate!= null)
ItemDelegate(nI ndex);
}
public event IImpBaseCollect ion__NewEnumEve ntHandler _NewEnumDelegat e = null;
public void Set__NewEnumDel egate(IImpBaseC ollection__NewE numEventHandler deleg)
{
_NewEnumDelegat e = deleg;
}
public bool Is__NewEnumDele gate(IImpBaseCo llection__NewEn umEventHandler deleg)
{
return (_NewEnumDelega te == deleg);
}
public void Clear__NewEnumD elegate()
{
_NewEnumDelegat e = null;
}
void _NewEnum () /* property get method */
{
if (_NewEnumDelega te!=null)
_NewEnumDelegat e();
}
}
Comment