C# WCF找不到与终结点的方案http匹配的基址
我在控制台应用程序中尝试托管WCF时遇到问题 Am获取异常: 异常:找不到与http方案匹配的基址 具有绑定WSHttpBinding的终结点。注册基址 计划为[] 这是我的代码:C# WCF找不到与终结点的方案http匹配的基址,c#,wcf,C#,Wcf,我在控制台应用程序中尝试托管WCF时遇到问题 Am获取异常: 异常:找不到与http方案匹配的基址 具有绑定WSHttpBinding的终结点。注册基址 计划为[] 这是我的代码: using System; using System.Collections.Generic; using System.Linq; using System.ServiceModel; using System.ServiceModel.Description; using System.Text; using S
using System;
using System.Collections.Generic;
using System.Linq;
using System.ServiceModel;
using System.ServiceModel.Description;
using System.Text;
using System.Threading.Tasks;
using WebServiceProject.Authentication;
using WebServiceProject.Automobili;
namespace ServerHostProject
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("--------WCF SERVICE------------");
Console.WriteLine("Starting WCF Services please wait...");
Console.WriteLine("-------------------------------------------");
// Host all services
try
{
// base address
Uri baseAddress = new Uri("http://localhost:50471/services/");
// initialize services
ServiceHost authenticationServiceHost = new ServiceHost(typeof(AuthenticationService));
ServiceHost automobilServiceHost = new ServiceHost(typeof(AutoService));
// end points
authenticationServiceHost.AddServiceEndpoint(typeof(IAuthenticationService), new WSHttpBinding(), "");
automobilServiceHost.AddServiceEndpoint(typeof(IAutoService), new WSHttpBinding(), "");
// metadata exchange
ServiceMetadataBehavior serviceBehavior = new ServiceMetadataBehavior();
serviceBehavior.HttpGetEnabled = true;
authenticationServiceHost.Description.Behaviors.Add(serviceBehavior);
automobilServiceHost.Description.Behaviors.Add(serviceBehavior);
// Open
authenticationServiceHost.Open();
automobilServiceHost.Open();
Console.WriteLine("Service is started now at : {0}", baseAddress);
Console.ReadKey();
authenticationServiceHost.Close();
automobilServiceHost.Close();
}
catch (Exception ex)
{
Console.WriteLine("Exception:" + ex.Message);
}
Console.ReadKey();
}
}
}
除了最后在控制台中引用“baseAddress”之外,你为什么不在任何地方使用它呢?我不知道这是我第一次使用WCF。给我一个例子,在通常情况下,调用“AddServiceEndpoint”的第三个参数(字符串),在上面的代码中当前是“”,应该是baseAddress变量。是的,我在方法定义中看到了。我设置了空字符串!谢谢