无法从方法组转换为

无法从方法组转换为

本文介绍了如何修复“无法从方法组转换为"Func<AsyncCallback, object, IAsyncResult>"?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

try
    {
      var login = ToServiceLogin(lgParameters);
      await Task.Factory.FromAsync(loginOperation.BeginLogin,
loginOperation.EndLogin, lgParameters, TaskCreationOptions.None);

    }
    catch (FaultException fe)
    {
        Debug.WriteLine(@"          {0}", fe.Message);
    }
    catch (Exception ex)
    {
        Debug.WriteLine(@"              ERROR {0}", ex.Message);
    }

Task.Factory.FromAsync 的第一个参数发生编译错误.我已经阅读了几个关于类似问题的线程,似乎没有一个帮助他们都提到这个具有不同的签名.请指出我正确的方向.

Compile error occurs on the first parameter of Task.Factory.FromAsync. I've read up on a couple of threads regarding similar issue none seems to be helping they all refer to this having a different signature. Please point me to the right direction.

使用签名编辑

开始登录签名

IAsyncResult BeginLogin(PRPClockingXamarin.PRPServiceMobile.LoginParameters loginParams,
                         AsyncCallback callback, object asyncState);

推荐答案

有一个很长的重载列表,但它似乎与您的不匹配

There is a long terse list of overloads but it seems it won't match your

IAsyncResult BeginLogin(
    LoginParameters loginParams,
    AsyncCallback callback,
    object asyncState);

作为

  Func<TArg1, AsyncCallback, object, IAsyncResult> beginMethod,

所以我建议为 Targ1 指定 Type 参数,

So I would suggest specifying the Type argument for Targ1,

FromAsync<PRPClockingXamarin.PRPServiceMobile.LoginParameters> (...)

还要验证 lgParameters 的类型是否正确.

also verify that lgParameters is of the correct type.

这篇关于如何修复“无法从方法组转换为"Func<AsyncCallback, object, IAsyncResult>"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-03 14:45