CS0536 Error

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Roland

    #1

    CS0536 Error

    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();

    }

    }

  • Ravikanth[MVP]

    #2
    CS0536 Error

    Hi

    The compiler did not detect an interface member
    implementation. A declaration may be present that almost
    implements the interface member. Check for the following
    syntax errors in the declaration for the interface
    member:

    public keyword is omitted.
    Return type does not match.
    static keyword is present.

    HTH
    Ravikanth[MVP]
    [color=blue]
    >-----Original Message-----
    >Hi All,
    >
    >I'm trying to generate a C# wrapper for a Windows type[/color]
    library using the following command line ...[color=blue]
    >
    >csc /target:library /doc:Interop.MyL ibrary.xml /unsafe[/color]
    Interop.MyLibra ry.cs >Interop.MyLibr ary.log[color=blue]
    >
    >And receiving the following error message ...
    >
    >Interop.MyLibr ary.cs(499,18): error[/color]
    CS0536: 'Interop.MyLibr ary.IImpBaseCol lection_SinkHel per'
    does not implement interface
    member 'Interop.MyLibr ary.IImpBaseCol lection.Item
    (object)'. 'Interop.MyLibr ary.IImpBaseCol lection_SinkHel pe
    r.Item(object)' is either static, not public, or has the
    wrong return type.[color=blue]
    >
    >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>[/color]
    interface.</para></summary>[color=blue]
    >[Guid("5616A320-AB4D-11D0-8E2F-00A0C9050603")]
    >
    >[ComImport]
    >
    >[TypeLibType((sh ort)4096)]
    >
    >[DefaultMember(" Item")]
    >
    >[InterfaceTypeAt tribute[/color]
    (ComInterfaceTy pe.InterfaceIsI Dispatch)][color=blue]
    >
    >public interface IImpBaseCollect ion:[/color]
    System.Collecti ons.IEnumerable[color=blue]
    >
    >{
    >
    >/// <summary><para> <c>Item</c> method of[/color]
    <c>IImpBaseColl ection</c> interface.</para></summary>[color=blue]
    >
    >/// <remarks><para> An original IDL definition of[/color]
    <c>Item</c> method was the following: <c>HRESULT Item
    (VARIANT nIndex, [out, retval] IDispatch** ReturnValue)
    </c>;</para></remarks>[color=blue]
    >
    >// IDL: HRESULT Item (VARIANT nIndex, [out, retval][/color]
    IDispatch** ReturnValue);[color=blue]
    >
    >// 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[/color]
    <c>IImpBaseColl ection</c> interface.</para></summary>[color=blue]
    >
    >/// <remarks><para> An original IDL definition of[/color]
    <c>_NewEnum</c> property was the following: <c>IUnknown*
    _NewEnum</c>;</para></remarks>[color=blue]
    >
    >// IDL: IUnknown* _NewEnum;
    >
    >// VB6: _NewEnum As IUnknown
    >
    >object _NewEnum
    >
    >{
    >
    >// IDL: HRESULT _NewEnum ([out, retval] IUnknown**[/color]
    ReturnValue);[color=blue]
    >
    >// VB6: Function _NewEnum As IUnknown
    >
    >[DispId(-4)]
    >
    >[return: MarshalAs(Unman agedType.IUnkno wn)]
    >
    >get;
    >
    >}
    >
    >/// <summary><para> Parent property of IImpBaseCollect ion[/color]
    interface.</para></summary>[color=blue]
    >
    >/// <remarks><para> An original IDL definition of[/color]
    <c>Parent</c> property was the following: <c>IDispatch*
    Parent</c>;</para></remarks>[color=blue]
    >
    >// 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[/color]
    interface.</para></summary>[color=blue]
    >
    >/// <remarks><para> An original IDL definition of[/color]
    <c>Count</c> property was the following: <c>long
    Count</c>;</para></remarks>[color=blue]
    >
    >// IDL: long Count;
    >
    >// VB6: Property Count As Long
    >
    >[DispId(3)]
    >
    >int Count
    >
    >{
    >
    >get;
    >
    >}
    >
    >}
    >
    >/// <summary><para> Delegate for handling <c>Item</c>[/color]
    event of <c>IImpBaseColl ection</c>
    interface.</para></summary>[color=blue]
    >
    >/// <remarks><para> An original IDL definition of[/color]
    <c>Item</c> event was the following: <c>HRESULT
    IImpBaseCollect ion_ItemEventHa ndler (VARIANT nIndex,
    [out, retval] IDispatch** ReturnValue)
    </c>;</para></remarks>[color=blue]
    >
    >// IDL: HRESULT IImpBaseCollect ion_ItemEventHa ndler[/color]
    (VARIANT nIndex, [out, retval] IDispatch** ReturnValue);[color=blue]
    >
    >// VB6: Function IImpBaseCollect ion_ItemEventHa ndler[/color]
    (ByVal nIndex As Any) As IDispatch[color=blue]
    >
    >[return: MarshalAs(Unman agedType.IDispa tch)]
    >
    >public delegate object[/color]
    IImpBaseCollect ion_ItemEventHa ndler (object nIndex);[color=blue]
    >
    >/// <summary><para> Delegate for handling <c>_NewEnum</c>[/color]
    event of <c>IImpBaseColl ection</c>
    interface.</para></summary>[color=blue]
    >
    >/// <remarks><para> An original IDL definition of[/color]
    <c>_NewEnum</c> event was the following: <c>HRESULT
    IImpBaseCollect ion__NewEnumEve ntHandler ([out, retval]
    IUnknown** ReturnValue)</c>;</para></remarks>[color=blue]
    >
    >// IDL: HRESULT IImpBaseCollect ion__NewEnumEve ntHandler[/color]
    ([out, retval] IUnknown** ReturnValue);[color=blue]
    >
    >// VB6: Function IImpBaseCollect ion__NewEnumEve ntHandler[/color]
    As IUnknown[color=blue]
    >
    >[return: MarshalAs(Unman agedType.IUnkno wn)]
    >
    >public delegate object[/color]
    IImpBaseCollect ion__NewEnumEve ntHandler () /* property
    get method */;[color=blue]
    >
    >/// <summary><para> Declaration of events of[/color]
    <c>IImpBaseColl ection</c> source
    interface.</para></summary>[color=blue]
    >
    >[ComEventInterfa ce(typeof(IImpB aseCollection), typeof[/color]
    (IImpBaseCollec tion_EventProvi der))][color=blue]
    >
    >[ComVisible(fals e)]
    >
    >public interface IImpBaseCollect ion_Event
    >
    >{
    >
    >/// <summary><para> <c>Item</c> event of[/color]
    <c>IImpBaseColl ection</c> interface.</para></summary>[color=blue]
    >
    >event IImpBaseCollect ion_ItemEventHa ndler Item;
    >
    >/// <summary><para> <c>_NewEnum</c> event of[/color]
    <c>IImpBaseColl ection</c> interface.</para></summary>[color=blue]
    >
    >event IImpBaseCollect ion__NewEnumEve ntHandler _NewEnum;
    >
    >}
    >
    >[ClassInterface( ClassInterfaceT ype.None)]
    >
    >internal class IImpBaseCollect ion_SinkHelper:[/color]
    IImpBaseCollect ion[color=blue]
    >
    >{
    >
    >public int Cookie = 0;
    >
    >public event IImpBaseCollect ion_ItemEventHa ndler[/color]
    ItemDelegate = null;[color=blue]
    >
    >public void Set_ItemDelegat e[/color]
    (IImpBaseCollec tion_ItemEventH andler deleg)[color=blue]
    >
    >{
    >
    >ItemDelegate = deleg;
    >
    >}
    >
    >public bool Is_ItemDelegate[/color]
    (IImpBaseCollec tion_ItemEventH andler deleg)[color=blue]
    >
    >{
    >
    >return (ItemDelegate == deleg);
    >
    >}
    >
    >public void Clear_ItemDeleg ate()
    >
    >{
    >
    >ItemDelegate = null;
    >
    >}
    >
    >void Item (object nIndex)
    >
    >{
    >
    >if (ItemDelegate!= null)
    >
    >ItemDelegate(n Index);
    >
    >}
    >
    >public event IImpBaseCollect ion__NewEnumEve ntHandler[/color]
    _NewEnumDelegat e = null;[color=blue]
    >
    >public void Set__NewEnumDel egate[/color]
    (IImpBaseCollec tion__NewEnumEv entHandler deleg)[color=blue]
    >
    >{
    >
    >_NewEnumDelega te = deleg;
    >
    >}
    >
    >public bool Is__NewEnumDele gate[/color]
    (IImpBaseCollec tion__NewEnumEv entHandler deleg)[color=blue]
    >
    >{
    >
    >return (_NewEnumDelega te == deleg);
    >
    >}
    >
    >public void Clear__NewEnumD elegate()
    >
    >{
    >
    >_NewEnumDelega te = null;
    >
    >}
    >
    >void _NewEnum () /* property get method */
    >
    >{
    >
    >if (_NewEnumDelega te!=null)
    >
    >_NewEnumDelega te();
    >
    >}
    >
    >}
    >[/color]

    Comment

    Working...