2012-02-21 87 views
2

我應該在DuplexClientBase構造函數的「endpointConfigurationName」參數中指定什麼?我應該在DuplexClientBase構造函數的「endpointConfigurationName」中指定什麼?

不管我放在那裏,客戶拋出execption,說「找不到,在ServiceModel客戶端配置單元參考合同‘ServiceReference1.IClientFulfillmentPipeService’默認終結點元素。這可能是因爲沒有配置文件找到您的應用程序,或者因爲在客戶端元素中找不到匹配此合同的端點元素。「

我使用「添加服務引用」嚮導生成代理。這裏是客戶端的源代碼:

class Program 
{ 
    static void Main() 
    { 
     try 
     { 
      var client = new ClientFulfillmentPipeServiceClient(new InstanceContext(new Wrapper()), "*", "net.tcp://localhost:9000/svc"); 
      client.Initialize(1234, "Test"); 
      client.Close(); 
     } 
     catch (Exception ex) 
     { 
      Debug.WriteLine(ex.Message); 
     } 
    } 
} 

而且我有示例WCF服務器寫入控制檯應用程序。這裏是執行:

static void Main() 
{ 
    UiWcfSession.OnInitialize += ClientInitialize; 

    var baseAddresses = new Uri("net.tcp://localhost:9000/"); 

    var host = new ServiceHost(typeof(UiWcfSession), baseAddresses); 

    var reliableSession = new ReliableSessionBindingElement { Ordered = true, InactivityTimeout = TimeSpan.MaxValue }; 
    var binding = 
     new CustomBinding(reliableSession, new TcpTransportBindingElement()) { ReceiveTimeout = TimeSpan.MaxValue }; 

    host.AddServiceEndpoint(typeof(IClientFulfillmentPipeService), binding, "svc"); 

    var metadataBehavior = new ServiceMetadataBehavior(); 
    host.Description.Behaviors.Add(metadataBehavior); 
    var mexBinding = MetadataExchangeBindings.CreateMexTcpBinding(); 
    host.AddServiceEndpoint(typeof(IMetadataExchange), mexBinding, "mex"); 

    host.Open(); 

    Thread.CurrentThread.Join(); 
} 

private static void ClientInitialize(int uiprocessid, string key) 
{ 
    Debug.WriteLine("ClientInitialize"); 
} 

我沒有使用XML配置。

你能幫我嗎?

回答

2

看起來像我不能使用這個構造函數,除非我添加.xml配置文件。

我結束了使用另一個需要CustomBindingEndpointAddress作爲參數。

相關問題