Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Very Specific C# to VB.NET Conversion Problem

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

I am attempting to convert some example code from C# into a codebase of an existing project of mine which is written in VB.NET and I've hit a problem.

The original line of code is:

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

Which I have converted to:

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

But - this is causing an error, "Argument not specified for parameter 'ev' of CheckHandshake".

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

I can see what the problem is, I'm just not really sure what to do about it! I've tried using 'AddressOf', but that doesn't seem to work, either.

Thanks in advance... - Chris

like image 281
Chris Roberts Avatar asked Dec 01 '25 17:12

Chris Roberts


1 Answers

Try

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

(using the AddressOf keyword to get a delegate)

like image 187
SLaks Avatar answered Dec 03 '25 10:12

SLaks



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!