C# 是否可以在WinForm中与AppServiceConnection和uwp通信
是否可以在WinForm中与AppServiceConnection和uwp通信?错误:不包含“GetWaiter”的定义,这是我的代码: 谢谢大家! 这是WinForm中的代码:C# 是否可以在WinForm中与AppServiceConnection和uwp通信,c#,winforms,uwp,C#,Winforms,Uwp,是否可以在WinForm中与AppServiceConnection和uwp通信?错误:不包含“GetWaiter”的定义,这是我的代码: 谢谢大家! 这是WinForm中的代码: private AppServiceConnection calculatorService; static Form1 mainForm; public Form1() { InitializeComponent(); } private async voi
private AppServiceConnection calculatorService;
static Form1 mainForm;
public Form1()
{
InitializeComponent();
}
private async void button1_Click(object sender, EventArgs e)
{
//Add the connection
if (calculatorService == null)
{
calculatorService = new AppServiceConnection();
calculatorService.AppServiceName = "com.yanscorp.appservicedemo.Values";
calculatorService.PackageFamilyName = "c97887ad-1f75-4b48-9e3b-21b89c061715_6evysfdvxt248";
var status = await calculatorService.OpenAsync();//A mistake here
if (status != AppServiceConnectionStatus.Success)
{
string d = "Failed to connect";
return;
}
}
var message = new ValueSet();
message.Add("Request", "GetCallCount");
AppServiceResponse response = await calculatorService.SendMessageAsync(message);//A mistake here
string result = "";
if (response.Status == AppServiceResponseStatus.Success)
{
result = response.Message["Response"] as string;
// Get the data that the service sent to us.
textBlock.Text = result;
}
}
错误:
错误 CS4036“IAsyncOperation”不包含“等待者”的定义,并且找不到可接受类型为“IAsyncOperation”的第一个参数的扩展方法“等待者”(是否缺少针对“系统”的 使用指令?) Windows窗体应用程序1
是否可以在WinForm中与AppServiceConnection和uwp通信
是的。您可以在WinForm中使用应用程序服务。请查看更多详细信息
错误:不包含“GetWaiter”的定义
您可以通过引用winmd
文件和System.Runtime.WindowsRuntime.dll
访问WinForm中的Windows 10 API。看起来您已经引用了winmd
,但是您可能忘记引用System.Runtime.WindowsRuntime.dll
,您可以在C:\Program Files>目录中找到它(x86)\Reference Assemblies\Microsoft\Framework\.NETCore\v4.5
添加
System.Runtime.WindowsRuntime.dll的引用将解决您的问题。详细信息请参考。如果您能够提供(文本,而不是图像),那就太棒了以及编译器错误的确切详细信息。请确保包含OpenAsync
方法的源代码。欢迎使用堆栈溢出。代码图像完全没有用处。有关避免发布图像的许多原因的列表,请参阅。代码和错误以文本形式发布,并且应该以文本形式发布。当您创建帐户时再次,有人建议你采取行动,阅读网页,以便熟悉本网站。请这样做,尤其是在发布下一个问题之前。此外,没有必要在标题和文本中重复标签信息。标签系统在这里工作得非常好,重复我的问题不需要任何帮助一次又一次的信息。添加标签并让它完成它的工作。非常感谢。我如何上传这个示例?我找不到上传的位置。帮助,非常感谢非常感谢您的回复,我已经实现了WinForm和uwp通过appService进行通信,但现在有一个问题,系统将随时终止appService时间,如何解决这个问题problem@Values如果您已经解决了当前的问题,请考虑标记为“接受”,以解决您的问题,并为您的新问题打开一个新的线程,或者给出关于您的问题的新链接。谢谢理解。