[英]WCF server not sending data to excel on another computer
I have a C# application which takes data in from a sensor. 我有一个C#应用程序,它从传感器中获取数据。
It has the code below: (unfortunately not written by me and not documented, and the old developer has long left the country). 它具有以下代码:(不幸的是,不是我写的,也没有记录在案的,而老开发商早已离开了这个国家)。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;
namespace Client
{
[ServiceContract]
public interface IDataRequest
{
[OperationContract]
string query(string instr, string attr);
}
public class DataRequest : IDataRequest
{
public string query(string symbol, string attr)
{
//data_set is a simple dictionary in another file
Data data = MAIN.data_set[symbol].Value;
return data.last;//numeric value of sensor reading
}
}
class WCFServer
{
ServiceHost host = null;
public void open()
{
host = new ServiceHost(
typeof(DataRequest),
new Uri[]{new Uri("net.pipe://localhost")});
host.AddServiceEndpoint(typeof(IDataRequest), new NetNamedPipeBinding(), "DataRequest");
try
{
host.Open();
}
catch (AddressAlreadyInUseException) { }
}
public void close()
{
try
{
host.Close();
}
catch (CommunicationObjectFaultedException) { }
}
}
}
Then in Excel, I can place in a cell: =RTD("data",,"sensor1","last"
然后在Excel中,我可以将其放置在单元格中: =RTD("data",,"sensor1","last"
Everything works fine on the one computer. 在一台计算机上,一切正常。
However, when I move the application and excel file to another computer, nothing works, instead of seeing the data value streaming into excel I just see #N/A. 但是,当我将应用程序和excel文件移动到另一台计算机时,没有任何效果,而不是看到数据值流入excel,而是看到#N / A。 The client application itself works on another computer, so i know the C# code is fine, just something to do with the WCF link from C# to Excel. 客户端应用程序本身可以在另一台计算机上工作,因此我知道C#代码很好,这与从C#到Excel的WCF链接有关。
Is there something else involved? 还有其他事情吗? Registration of the WCF server or anything? WCF服务器注册或其他?
在RTD中添加服务器名称:RTD(“ data,server_name,” sensor1“,” last“)。文档: https : //support.microsoft.com/zh-cn/kb/289150
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.