C# 从Windows应用程序调用WCF-主机

C# 从Windows应用程序调用WCF-主机,c#,wcf,C#,Wcf,我的解决方案中有4个项目。2个WCF服务库项目,称为GetDetfromDB,ModifyDBService,一个控制台应用程序,其中引用了这些WCF服务库,一个windows应用程序调用此WCF服务 我在windows应用程序中引用了控制台应用程序。现在我可以从窗口应用程序调用客户端应用程序 但现在我如何通过从windows应用程序调用来调用console应用程序中引用的服务 注意:当我按F5或调试器-->启动新实例时,这两个服务都能从我的控制台正确运行。我正确配置了所有绑定、端点地址。我想知

我的解决方案中有4个项目。2个WCF服务库项目,称为
GetDetfromDB
ModifyDBService
,一个控制台应用程序,其中引用了这些WCF服务库,一个windows应用程序调用此WCF服务

我在windows应用程序中引用了控制台应用程序。现在我可以从窗口应用程序调用客户端应用程序

但现在我如何通过从windows应用程序调用来调用console应用程序中引用的服务

注意:当我按F5或调试器-->启动新实例时,这两个服务都能从我的控制台正确运行。我正确配置了所有绑定、端点地址。我想知道如何以编程方式调用它

以下是我的控制台应用程序代码:

namespace ServiceHostConsole
{
    public class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("enter to start");
            Console.Read();

            Type serviceType = typeof(GetDetfromDB.ImpService);
            Type serviceModifyDB = typeof(ModifyDBService.Manipulate);

            ServiceHost host1 = new ServiceHost(serviceModifyDB);
            host1.Open();

            using (ServiceHost host = new ServiceHost(serviceType))
            {
                host.Open();

                Console.WriteLine("The Product Service is available");
                Console.ReadLine(); host.Close();
            }

            Console.WriteLine("Please enter to close modify service");
            Console.Read();
            host1.Close();
        }

        public string returnPath()
        {
            string folder = Environment.CurrentDirectory;
            return folder;
        }
    }
}
在Windows应用程序中,我是这样呼叫的

 public Form1()
 {
      InitializeComponent();

      ServiceHostConsole.Program pb = new ServiceHostConsole.Program();
      Process.Start(pb.returnPath()+ @"\ServiceHostConsole.exe");
 }
现在,当程序试图打开我的服务时,我遇到以下错误

服务“ModifyDBService.Operation”没有应用程序 (非基础设施)端点。这可能是因为没有 找不到应用程序的配置文件,或者因为没有 在中可以找到与服务名称匹配的服务元素 配置文件,或者因为在 服务要素

我怀疑我只是盲目地调用方法,而不是调用服务

请帮助我摆脱这个问题,我已经为此奋斗了5天

我需要发布我的windows应用程序,当我单击“设置”时,我的windows应用程序和调用了服务的客户端应用程序都应该打开。这是我的要求

ServiceHostConsole的我的App.config如下所示

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <system.serviceModel>
        <services>
            <service name="GetDetfromDB.ImpService">
                <endpoint address="http://localhost:8080/MyService" binding="basicHttpBinding"
                    bindingConfiguration="" contract="GetDetfromDB.IGetExpenseValuestype" />
            </service>
            <service name="ModifyDBService.Manipulate">
                <endpoint address="http://localhost:8081/MyService1." binding="basicHttpBinding"
                    bindingConfiguration="" contract="ModifyDBService.IManipulateDB" />
            </service>
        </services>
    </system.serviceModel>
</configuration>

不要引用WCF服务库。它们只能从托管服务的项目中引用

相反,您应该使用“添加服务引用”来引用服务


请参阅“”

ServiceHostConsole应用程序的
app.config
是什么样子的?我们需要查看
标记中的所有内容