I keep getting this error and not sure how to correct it
Error 1 Cannot use 'Callback' as an argument to a dynamically dispatched operation because it is a method group. Did you intend to invoke the method?
//...
if (e.Status == LiveConnectSessionStatus.Connected)
{
client = new LiveConnectClient(e.Session);
LiveOperationResult operationResult = await client.GetAsync("me");
try
{
dynamic meResult = operationResult.Result;
var openId = meResult.id;
var email = meResult.emails.preferred;
//MessageBox.Show(openId);
//MessageBox.Show(email);
userService.SignIn(openId, email, Callback);
}
catch (LiveConnectException exception)
{
MessageBox.Show("Error calling API: " + exception.Message);
}
}
}
private void Callback(ErrorModel error)
{
if (error != null)
{
MessageBox.Show(error.FriendlyErrorMsg, error.Caption, MessageBoxButton.OK);
}
else
{
}
}
public void SignIn(string id, string email, Action<ErrorModel> callBack)
{
}
This feature allows you to specify a custom redirect URL. This URL will be sent to the server as the redirect_uri parameter. This feature can be used to redirect the user to your application where you will use the code/access_token as required.
The @app. callback decorator needs to be directly above the callback function declaration. If there is a blank line between the decorator and the function definition, the callback registration will not be successful.
As of dash v1. 19.0 , you can create circular updates within the same callback. Circular callback chains that involve multiple callbacks are not supported.
Callbacks are python decorators that control the interactivity of your dash app. A decorator is a function that wraps around another function, executing code before and/or after the function they decorate.
The problem is that this call is dynamic:
userService.SignIn(openId, email, Callback);
It has to be, because openId
and email
are inferred to be of type dynamic
:
var openId = meResult.id;
var email = meResult.emails.preferred;
You can't use a method group conversion like this in a dynamic call - it's just one of the restrictions of using dynamic
.
So, options:
Give openId
and email
explicit types, which (if userService
isn't dynamic
) will make the call non-dynamic, at which the method group conversion will work. This just means specifying the types explicitly, as there's an implicit conversion available from dynamic
:
string openId = meResult.id;
string email = meResult.emails.preferred;
userService.SignIn(openId, email, Callback);
Create a specific delegate type instance from the Callback
method, if you want to keep the SignIn
call dynamic:
var openId = meResult.id;
var email = meResult.emails.preferred;
// Or use whichever delegate type is actually appropriate for SignIn
userService.SignIn(openId, email, new Action<ErrorModel>(Callback));
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With