要实现ASP.NET Website
和C# application
之间的沟通渠道,我遵循了以下示例:
https://dopeydev.com/wcf-interprocess-communication/
在我的HTML中,我有ASP.NET Label
:
<asp:Label runat="server" id="label"></asp:Label>
这是页面背后的代码:
using Interfaces;
using System;
using System.ServiceModel;
using System.Web.Services;
using System.Web.UI;
public partial class _Default : Page
{
static IService service;
protected void Page_Load(object sender, EventArgs e)
{
var callback = new Callback();
var context = new InstanceContext(callback);
var pipeFactory = new DuplexChannelFactory<IService>(context, new NetNamedPipeBinding(), new EndpointAddress("net.pipe://localhost/ipc"));
try
{
service = pipeFactory.CreateChannel();
service.Connect();
System.Diagnostics.Debug.WriteLine("Server connected!");
}
catch (EndpointNotFoundException)
{
System.Diagnostics.Debug.WriteLine("Server not found");
}
}
}
public class Callback : ICallbackService
{
public void SendCallbackMessage(string message)
{
// label.Text = message;
}
}
当我收到来自其他应用程序的消息时,在&#34; Callback&#34;上课时,我想访问&#34;标签&#34;控制网页。
我不明白如何从这个外部类中检索html控件。