0

我有一个我在 2011 年用 c# 构建的应用程序,它有一个 WCFServer:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ServiceModel;

namespace Atlantic_Client
{
    [ServiceContract]
    public interface IDataRequest
    {
        [OperationContract]
        string query(string instr, string attr);
    }

public class DataRequest : IDataRequest
{
    public string query(string symbol, string attr)
    {
                    if (attr == "test")
                    {
                        try
                        {
                            return 55;
                        }
                        catch (Exception) { }

                        return 55;
                    }
                    else
                    {
                        return "Bad Attribute";
                    }

            return "UNKNOWN";
        }
    }
}

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) { }
    }

}

}

这个类在我的旧计算机上完美运行,使用 Visual Basic 2008(我每次只是将程序作为调试而不是独立应用程序运行)和 Excel 2007。

但是,我有一台新电脑,安装了 Visual Studio 2008 和 Excel 2010,当我尝试同样的事情时,它根本不起作用。

excel RTD 单元格只返回 #N/A

4

0 回答 0