gpt4 book ai didi

c# - MobileServiceClient.LoginAsync() 引发方法 'LoginAsync' 没有重载需要 1 个参数错误

转载 作者:太空宇宙 更新时间:2023-11-03 23:40:33 26 4
gpt4 key购买 nike

我正在尝试将一些通用代码(例如用户登录)放入类库(可移植的通用应用程序)项目中,而不是标准的空白通用应用程序项目中。

不幸的是,我无法构建类库,因为此代码片段会引发错误:

No overload for method 'LoginAsync' takes 1 arguments

代码:

    using Microsoft.WindowsAzure.MobileServices;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Mobile.Common
{
public class UserHandler
{
/// ... properties, etc...

public async Task<bool> LoginAsync(MobileServiceAuthenticationProvider provider)
{
this.currentUser = await MobileService.LoginAsync(provider); //error occurs here
/// other code goes here...

}
}
}

我为我的类库项目安装了 Azure 移动服务 Nuget 包。基于以下论坛,我很清楚,在 Win8.1 或 WinPhone8.1 中,此代码可以正常工作:https://social.msdn.microsoft.com/Forums/en-US/720f607d-ad28-4d6b-b5e1-54145b243206/mobile-service-authentication?forum=azuremobile

但我不知道如何在我的类库项目中修复它。 ?

最佳答案

您正在调用的 LoginAsync() 方法是特定于平台的方法,定义为平台特定 dll 中客户端的扩展,因此无法从 PCL 中使用。

如果您查看 MobileServiceClient 的 PCL 版本,您会发现它仅支持您已从身份提供商获得 token 的登录。

https://github.com/Azure/azure-mobile-services/blob/master/sdk/Managed/src/Microsoft.WindowsAzure.MobileServices/MobileServiceClient.cs

以下是 Windows 应用商店如何为 Win 应用商店添加基于服务器的身份验证 UI(使用 Windows 身份验证代理)

https://github.com/Azure/azure-mobile-services/blob/master/sdk/Managed/src/Microsoft.WindowsAzure.MobileServices.WindowsStore/Extensions/MobileServiceClientExtensions.cs

关于c# - MobileServiceClient.LoginAsync() 引发方法 'LoginAsync' 没有重载需要 1 个参数错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29146335/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com