简体   繁体   中英

VB.NET Class implements event

I don't see what I did wrong.

The IDE tells me

 "Class 'CaptureDevice' needs to implement event 'Event NewFrame(sender As Object, e As CameraEventArgs) for 'IVideoSource'.

The class 'CaptureDevice' looks like this:

Imports System.Drawing
Imports System.Drawing.Imaging
Imports System.IO
Imports System.Threading
Imports System.Runtime.InteropServices
Imports System.Net
Imports dshow
Imports dshow.Core

Namespace VideoSource

    Public Class CaptureDevice
        Implements IVideoSource
        Private source As String
        Private m_userData As Object = Nothing
        Private m_framesReceived As Integer

        Private thread As Thread = Nothing
        Private stopEvent As ManualResetEvent = Nothing

        ' new frame event '
        Public Event NewFrame As CameraEventHandler

        '(...)'
    End Class
End Namespace

My class 'IVideoSource' looks like this:

Namespace VideoSource

    'IVideoSource interface'
    Public Interface IVideoSource

        Event NewFrame As CameraEventHandler

    End Interface

End Namespace

Does anybody see where I went wrong or what may be missing?

Thank you very much for the help!

In your CaptureDevice class, do this instead:

Public Event NewFrame As CameraEventHandler Implements IVideoSource.NewFrame

While C# assumes a public member with the same name of an implemented interface's member to be the implementation, VB.NET requires that implementations are declared explicitely.

You need to add the Implements clause, so, something like:

Public Event NewFrame As CameraEventHandler Implements IVideoSource.NewFrame

VB.Net does not have c#'s implicit interface implementation.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM