C# WCF服务错误没有配置文件或端点.Net 3.5

C# WCF服务错误没有配置文件或端点.Net 3.5,c#,wcf,C#,Wcf,我正在编写WCF服务-客户端。服务正在以arg形式获取端点url,这是Windows窗体应用程序。 服务impl是: BaseAddress = new Uri(args[0]); using (ServiceHost host = new ServiceHost(typeof(DriverService), BaseAddress)) { ServiceMetadataBehavior smb = new ServiceMetadataBehavior(); smb.HttpGet

我正在编写WCF服务-客户端。服务正在以arg形式获取端点url,这是Windows窗体应用程序。
服务impl是:

BaseAddress = new Uri(args[0]);
using (ServiceHost host = new ServiceHost(typeof(DriverService), BaseAddress))
{
   ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
   smb.HttpGetEnabled = true;
   smb.MetadataExporter.PolicyVersion = PolicyVersion.Policy15;
   host.Description.Behaviors.Add(smb);
 //host.AddServiceEndpoint(typeof(DriverService), new BasicHttpBinding(), BaseAddress);
   host.Open();
在host.Open()之后,我得到了一个错误,当我在另一个解决方案上编写相同的wcf代码时,它工作得很好,我有客户端和服务。现在我只需要在等待客户端连接时打开服务

据我所知,这是一个服务,我给它一个地址,然后它监听给定的地址,并将接口上的方法公开给不同的客户端

错误:

Service 'DriverHost.DriverService' has zero application (non-infrastructure) endpoints. This might be because no configuration file was found for your application, or because no service element matching the service name could be found in the configuration file, or because no endpoints were defined in the service element.  
接口和类的代码:

[ServiceContract]
public interface IDriverService
{
    [OperationContract]
    string WhoAmI();
}

public class DriverService : IDriverService
{
    public string WhoAmI()
    {
        return string.Format("Im on port !");
    }
}

由于.net 4.5和3.5之间存在差异,我理解没有默认端点。
因此需要声明:

BaseAddress = new Uri(args[0]);
using (ServiceHost host = new ServiceHost(typeof(Namespace.Classname), BaseAddress))
{
  ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
  smb.HttpGetEnabled = true;
  smb.MetadataExporter.PolicyVersion = PolicyVersion.Policy15;
  host.Description.Behaviors.Add(smb);
  host.AddServiceEndpoint(typeof(Namespace.IInterface), new BasicHttpBinding(), args[0]);
  host.Open();
含义-添加.AddServiceEndpoint(..)
并确保在ServiceHost()上编写类,在AddServiceEndpoint上输入接口。

您的app.config中是否有绑定我的app.config中没有任何绑定,但在我制作的示例中,我没有编写任何绑定,这可能是重复的…检查答案…我假设您得到的错误在客户端。在启动客户端应用程序之前,服务器是否已运行?