3

这是我的代码,VS2012 C# Express 抱怨接口 PISDK._DEventPipeEvents 中的两个成员没有实现,这里快速粘贴:

    namespace PISDK
{
    [Guid("9E679FD2-DE8C-11D3-853F-00C04F45D1DA")]
    [InterfaceType(2)]
    [TypeLibType(4096)]
    public interface _DEventPipeEvents
    {
        [DispId(2)]
        void OnNewValue();
        [DispId(1)]
        void OnOverflow(object vtEvent, OverflowCauseConstants Cause);
    }
}

这是我的代码:

class PointListEventPipeEventReceiver : PISDK._DEventPipeEvents
{
    private PISDK.EventPipe eventPipe;

    public PointListEventPipeEventReceiver(PISDK.EventPipe eventPipe)
    {
        this.eventPipe = eventPipe;
    }

    public void PISDK._DEventPipeEvents.OnNewValue()
    {
        Console.WriteLine("New value event");
        handleNewValue(eventPipe);
    }

    public void PISDK._DEventPipeEvents.OnOverFlow(object vtEvent, PISDK.OverflowCauseConstants Cause)
    {
        throw new NotImplementedException();
    }

    private void handleNewValue(PISDK.EventPipe eventPipe)
    {
        Console.WriteLine("Handling new value");
        Array eventObjs = eventPipe.TakeAll();
        Console.WriteLine("eventObjs.Length==" + eventObjs.Length);
        foreach (PISDK.PIEventObject piEventObj in eventObjs)
        {
            Console.WriteLine(piEventObj.EventData as PISDK.PointValue);
        }
    }
}

我在这里不知所措,任何帮助都很好。

4

2 回答 2

5

您的实现在接口中使用OnOverFlow大写F字母而不是小写字母。应该调用该方法OnOverflow

于 2012-09-29T03:16:31.663 回答
4

除了在“溢出”中出现错误之外,看起来您正在尝试将public访问修饰符应用于显式接口成员实现。您可以将成员隐式实现为公共成员,也可以显式实现,但不能同时实现。

隐式实现:

public void OnOverflow(object vtEvent, PISDK.OverflowCauseConstants Cause) 
{ 
    throw new NotImplementedException(); 
} 

显式实现:

void PISDK._DEventPipeEvents.OnOverflow(object vtEvent, PISDK.OverflowCauseConstants Cause) 
{ 
    throw new NotImplementedException(); 
} 
于 2012-09-29T05:55:17.757 回答