Error CS0536

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

    #1

    Error CS0536

    Sorry for Cross-Posting ^O^


    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[color=blue]
    >Interop.MyLibr ary.log[/color]

    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....

    (Line 499
    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 )]

    // ***** THIS IS LINE 499 ********
    public interface IImpBaseCollect ion: System.Collecti ons.IEnumerable
    {

    [DispId(0)]
    [return: MarshalAs(Unman agedType.IDispa tch)]
    object Item (object nIndex);

    object _NewEnum
    {

    [DispId(-4)]

    [return: MarshalAs(Unman agedType.IUnkno wn)]

    get;

    }

    [DispId(2)]

    object Parent

    {

    [return: MarshalAs(Unman agedType.IDispa tch)]

    get;

    }

    [DispId(3)]

    int Count
    {
    get;
    }

    }


    [return: MarshalAs(Unman agedType.IDispa tch)]
    public delegate object IImpBaseCollect ion_ItemEventHa ndler (object nIndex);


    [return: MarshalAs(Unman agedType.IUnkno wn)]
    public delegate object IImpBaseCollect ion__NewEnumEve ntHandler () /*
    property get method */;


    [ComEventInterfa ce(typeof(IImpB aseCollection), typeof(IImpBase Collection_Even
    tProvider))]
    [ComVisible(fals e)]

    public interface IImpBaseCollect ion_Event

    {
    event IImpBaseCollect ion_ItemEventHa ndler Item;
    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();
    }

    }



  • Dmitriy Lapshin [C# / .NET MVP]

    #2
    Re: Error CS0536

    Hi Roland,

    You inherit the following class:

    IImpBaseCollect ion_SinkHelper

    from IImpBaseCollect ion and therefore have to implement all methods and
    properties declared in this interface. On the other hand, you have an Item
    method in this class that is declared in the IImpBaseCollect ion interface,
    but the IImpBaseCollect ion_SinkHelper. Item returns "void" while
    IImpBaseCollect ion.Item should return "object". This causes a conflict the
    compiler complains about:
    [color=blue]
    > 'Interop.MyLibr ary.IImpBaseCol lection_SinkHel per.Item(object )' is either
    > static, not public, or has the wrong return type.[/color]
    ^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^

    --
    Dmitriy Lapshin [C# / .NET MVP]
    X-Unity Test Studio

    Bring the power of unit testing to VS .NET IDE

    "Roland" <roland.macpher son@sympatico.c a> wrote in message
    news:XHRcb.1142 1$yD1.1466273@n ews20.bellgloba l.com...[color=blue]
    > Sorry for Cross-Posting ^O^
    >
    >
    > 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[/color]
    Interop.MyLibra ry.cs[color=blue][color=green]
    > >Interop.MyLibr ary.log[/color]
    >
    > 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....
    >
    > (Line 499
    > 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 )]
    >
    > // ***** THIS IS LINE 499 ********
    > public interface IImpBaseCollect ion: System.Collecti ons.IEnumerable
    > {
    >
    > [DispId(0)]
    > [return: MarshalAs(Unman agedType.IDispa tch)]
    > object Item (object nIndex);
    >
    > object _NewEnum
    > {
    >
    > [DispId(-4)]
    >
    > [return: MarshalAs(Unman agedType.IUnkno wn)]
    >
    > get;
    >
    > }
    >
    > [DispId(2)]
    >
    > object Parent
    >
    > {
    >
    > [return: MarshalAs(Unman agedType.IDispa tch)]
    >
    > get;
    >
    > }
    >
    > [DispId(3)]
    >
    > int Count
    > {
    > get;
    > }
    >
    > }
    >
    >
    > [return: MarshalAs(Unman agedType.IDispa tch)]
    > public delegate object IImpBaseCollect ion_ItemEventHa ndler (object[/color]
    nIndex);[color=blue]
    >
    >
    > [return: MarshalAs(Unman agedType.IUnkno wn)]
    > public delegate object IImpBaseCollect ion__NewEnumEve ntHandler () /*
    > property get method */;
    >
    >
    >[/color]
    [ComEventInterfa ce(typeof(IImpB aseCollection), typeof(IImpBase Collection_Even[color=blue]
    > tProvider))]
    > [ComVisible(fals e)]
    >
    > public interface IImpBaseCollect ion_Event
    >
    > {
    > event IImpBaseCollect ion_ItemEventHa ndler Item;
    > 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();
    > }
    >
    > }
    >
    >
    >[/color]

    Comment

    Working...