Very specific issue of converting C # to VB.NET

I am currently working on a project that uses the AutoFac Inversion of Control container.

I am trying to convert example code from C # to the code base of my existing project, which is written in VB.NET, and I ran into a problem.

Source line of code:

EventHub.Subscribe<HandshakingEvent>(container.Resolve<HandshakeAuthenticator>().CheckHandshake);

Which I converted to:

EventHub.Subscribe(Of HandshakingEvent)(Container.Resolve(Of HandshakeAuthenticator)().CheckHandshake)

But - this causes an error: "The argument is not specified for the parameter" ev "CheckHandshake".

The parameter type for the EventHub.Subscribe (Of HandshakingEvent) procedure is System.Action (of HandshakingEvent)

I see what the problem is, I'm just not sure what to do with it! I tried using "AddressOf", but that does not work either.

Thanks in advance ... - Chris

+3
2

Try

EventHub.Subscribe(Of HandshakingEvent)(AddressOf Container.Resolve(Of HandshakeAuthenticator)().CheckHandshake)

( AddressOf, )

+5

VB . AddresOf, deletegate:

EventHub.Subscribe(Of HandshakingEvent)(AddressOf Container.Resolve(Of HandshakeAuthenticator)().CheckHandshake)

#, , VB .

+3

Source: https://habr.com/ru/post/1773549/


All Articles