Error CS0536

R

Roland

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.MyLibrary.xml /unsafe Interop.MyLibrary.cs
Interop.MyLibrary.log

And receiving the following error message ...

Interop.MyLibrary.cs(499,18): error CS0536:
'Interop.MyLibrary.IImpBaseCollection_SinkHelper' does not implement
interface member 'Interop.MyLibrary.IImpBaseCollection.Item(object)'.
'Interop.MyLibrary.IImpBaseCollection_SinkHelper.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>IImpBaseCollection</c> interface.</para></summary>
[Guid("5616A320-AB4D-11D0-8E2F-00A0C9050603")]
[ComImport]
[TypeLibType((short)4096)]
[DefaultMember("Item")]
[InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIDispatch)]

// ***** THIS IS LINE 499 ********
public interface IImpBaseCollection: System.Collections.IEnumerable
{

[DispId(0)]
[return: MarshalAs(UnmanagedType.IDispatch)]
object Item (object nIndex);

object _NewEnum
{

[DispId(-4)]

[return: MarshalAs(UnmanagedType.IUnknown)]

get;

}

[DispId(2)]

object Parent

{

[return: MarshalAs(UnmanagedType.IDispatch)]

get;

}

[DispId(3)]

int Count
{
get;
}

}


[return: MarshalAs(UnmanagedType.IDispatch)]
public delegate object IImpBaseCollection_ItemEventHandler (object nIndex);


[return: MarshalAs(UnmanagedType.IUnknown)]
public delegate object IImpBaseCollection__NewEnumEventHandler () /*
property get method */;


[ComEventInterface(typeof(IImpBaseCollection),typeof(IImpBaseCollection_Even
tProvider))]
[ComVisible(false)]

public interface IImpBaseCollection_Event

{
event IImpBaseCollection_ItemEventHandler Item;
event IImpBaseCollection__NewEnumEventHandler _NewEnum;
}

[ClassInterface(ClassInterfaceType.None)]

internal class IImpBaseCollection_SinkHelper: IImpBaseCollection
{
public int Cookie = 0;
public event IImpBaseCollection_ItemEventHandler ItemDelegate = null;
public void Set_ItemDelegate(IImpBaseCollection_ItemEventHandler deleg)
{

ItemDelegate = deleg;
}

public bool Is_ItemDelegate(IImpBaseCollection_ItemEventHandler deleg)
{
return (ItemDelegate == deleg);
}

public void Clear_ItemDelegate()
{
ItemDelegate = null;
}

void Item (object nIndex)

{

if (ItemDelegate!=null)

ItemDelegate(nIndex);

}

public event IImpBaseCollection__NewEnumEventHandler _NewEnumDelegate =
null;
public void Set__NewEnumDelegate(IImpBaseCollection__NewEnumEventHandler
deleg)

{
_NewEnumDelegate = deleg;
}

public bool Is__NewEnumDelegate(IImpBaseCollection__NewEnumEventHandler
deleg)
{
return (_NewEnumDelegate == deleg);
}

public void Clear__NewEnumDelegate()
{
_NewEnumDelegate = null;
}

void _NewEnum () /* property get method */
{
if (_NewEnumDelegate!=null)
_NewEnumDelegate();
}

}
 
D

Dmitriy Lapshin [C# / .NET MVP]

Hi Roland,

You inherit the following class:

IImpBaseCollection_SinkHelper

from IImpBaseCollection 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 IImpBaseCollection interface,
but the IImpBaseCollection_SinkHelper.Item returns "void" while
IImpBaseCollection.Item should return "object". This causes a conflict the
compiler complains about:
'Interop.MyLibrary.IImpBaseCollection_SinkHelper.Item(object)' is either
static, not public, or has the wrong return type.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^

--
Dmitriy Lapshin [C# / .NET MVP]
X-Unity Test Studio
http://x-unity.miik.com.ua/teststudio.aspx
Bring the power of unit testing to VS .NET IDE

Roland said:
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.MyLibrary.xml /unsafe Interop.MyLibrary.cs
Interop.MyLibrary.log

And receiving the following error message ...

Interop.MyLibrary.cs(499,18): error CS0536:
'Interop.MyLibrary.IImpBaseCollection_SinkHelper' does not implement
interface member 'Interop.MyLibrary.IImpBaseCollection.Item(object)'.
'Interop.MyLibrary.IImpBaseCollection_SinkHelper.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>IImpBaseCollection</c> interface.</para></summary>
[Guid("5616A320-AB4D-11D0-8E2F-00A0C9050603")]
[ComImport]
[TypeLibType((short)4096)]
[DefaultMember("Item")]
[InterfaceTypeAttribute(ComInterfaceType.InterfaceIsIDispatch)]

// ***** THIS IS LINE 499 ********
public interface IImpBaseCollection: System.Collections.IEnumerable
{

[DispId(0)]
[return: MarshalAs(UnmanagedType.IDispatch)]
object Item (object nIndex);

object _NewEnum
{

[DispId(-4)]

[return: MarshalAs(UnmanagedType.IUnknown)]

get;

}

[DispId(2)]

object Parent

{

[return: MarshalAs(UnmanagedType.IDispatch)]

get;

}

[DispId(3)]

int Count
{
get;
}

}


[return: MarshalAs(UnmanagedType.IDispatch)]
public delegate object IImpBaseCollection_ItemEventHandler (object nIndex);


[return: MarshalAs(UnmanagedType.IUnknown)]
public delegate object IImpBaseCollection__NewEnumEventHandler () /*
property get method */;


[ComEventInterface(typeof(IImpBaseCollection),typeof(IImpBaseCollection_Even
tProvider))]
[ComVisible(false)]

public interface IImpBaseCollection_Event

{
event IImpBaseCollection_ItemEventHandler Item;
event IImpBaseCollection__NewEnumEventHandler _NewEnum;
}

[ClassInterface(ClassInterfaceType.None)]

internal class IImpBaseCollection_SinkHelper: IImpBaseCollection
{
public int Cookie = 0;
public event IImpBaseCollection_ItemEventHandler ItemDelegate = null;
public void Set_ItemDelegate(IImpBaseCollection_ItemEventHandler deleg)
{

ItemDelegate = deleg;
}

public bool Is_ItemDelegate(IImpBaseCollection_ItemEventHandler deleg)
{
return (ItemDelegate == deleg);
}

public void Clear_ItemDelegate()
{
ItemDelegate = null;
}

void Item (object nIndex)

{

if (ItemDelegate!=null)

ItemDelegate(nIndex);

}

public event IImpBaseCollection__NewEnumEventHandler _NewEnumDelegate =
null;
public void Set__NewEnumDelegate(IImpBaseCollection__NewEnumEventHandler
deleg)

{
_NewEnumDelegate = deleg;
}

public bool Is__NewEnumDelegate(IImpBaseCollection__NewEnumEventHandler
deleg)
{
return (_NewEnumDelegate == deleg);
}

public void Clear__NewEnumDelegate()
{
_NewEnumDelegate = null;
}

void _NewEnum () /* property get method */
{
if (_NewEnumDelegate!=null)
_NewEnumDelegate();
}

}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top