私はこのソフトウェアをC#でコーディングしています。このエラーメッセージが表示されます。私の人生にとって、私はそれを理解することはできません。私が何をしていても、何か役立つものを探しているわけではありません。あなたの問題はここにある'System.Threading.Tasks.Task'タイプを 'Windows.Foundation.IAsyncAction'に暗黙的に変換することはできません。明示的な変換が存在する
private async Task LoginIoTHub()
{
TypeJson command_json = new TypeJson();
if (NowNetSta == false) return;
if (IoTHubConnectFlag == false) return;
if (TeamName == null)
{
Debug.WriteLine("Please don't let your team name be void when you call methods 'new IoTHubLocalService(xx,xx,xx)'");
await Task.Delay(TimeSpan.FromSeconds(4));
}
else
{
if (LoginF == false)
{
try
{
Debug.WriteLine("Start to login\r\n");
LoginJson login_msg = new LoginJson();
login_msg.DeviceID = BoardID;
login_msg.name = TeamName;
var messageString = JsonConvert.SerializeObject(login_msg);
command_json.Type = 1;
command_json.Command = messageString;
messageString = JsonConvert.SerializeObject(command_json);
var message = new Message(Encoding.ASCII.GetBytes(messageString));
IAsyncAction Action = deviceClient.SendEventAsync(message);
await Action;
if (Action.Status == AsyncStatus.Completed)
{
Debug.WriteLine("Login success");
LoginF = true;
}
else
{
Debug.WriteLine("Login failed");
await Task.Delay(TimeSpan.FromSeconds(10));
}
}
catch (Exception ex)
{
Debug.WriteLine("Login to IoT Hub failed, please check your team name and internet connection: " + ex.Message);
await Task.Delay(TimeSpan.FromSeconds(10));
}
}
}
}
を使用して完了を確認することができます。それは 'IAsyncAction Action = deviceClient.SendEventAsync(message);'あなたの問題だと推測しています。 – Nkosi