I'm trying to implement the PTPrincipal class in VB.Net, and the direct translation of the C# class produces an error...
Anyone know what the correct syntax should be?
Here's what I get in VB.Net :
Public Shared Sub BeginLogin(username As String, password As String)
PTIdentity.GetPTIdentity(username, password, Function(o, e)
If e.[Error] Is Nothing AndAlso e.[Object] IsNot Nothing Then
End Function) '------ doesn't like THIS function aspect.
when I translate THIS code from C#:
public static void BeginLogin(string username, string password)
PTIdentity.GetPTIdentity(username, password, (o, e) =>
if (e.Error == null && e.Object != null)
The design-time error (warning) is:
Function '<anonymous method>' doesn't return a value on all code paths. A null reference exception could occur at run time when the result is used.
I suspect this is the translator implementing the function incorrectly, but I'm not familiar with the syntax.
I don't know a lot about lambdas in VB.NET, but I'm guessing the issue is that the lambda expression is being defined as a function, but the expression doesn't return anything. So my best suggestion is to replace "Function(o, e)" to "Sub(o, e)" (and the corresponding "End" tag too).
Hmmm... a Sub seems to correct the error... I wonder if there's any impact....
I'm pretty sure the C# code method is void, so then Sub would be the correct translation.
VB.Net looks like this:
Public Shared Sub BeginLogin(ByVal username As String, ByVal password As String)
CustomIdentity.GetIdentity(username, password, Sub(o, e)
If e.Error Is Nothing AndAlso e.Object IsNot Nothing Then
Copyright (c) Marimer LLC