我应该在“endpointConfigurationName”中指定什么DuplexClientBase 构造函数?
我应该在 DuplexClientBase 构造函数的“endpointConfigurationName”参数中指定什么?
无论我在那里放什么,客户端都会抛出这样的可执行文件:“在 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 配置。
请你帮助我好吗 ?
What should I specify in "endpointConfigurationName" parameter of DuplexClientBase constructor ?
No matter what I put there client throws execption that says "Could not find default endpoint element that references contract 'ServiceReference1.IClientFulfillmentPipeService' in the ServiceModel client configuration section. This might be because no configuration file was found for your application, or because no endpoint element matching this contract could be found in the client element."
I generated proxy using "Add Service Reference" wizard. Here is source code of the client:
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);
}
}
}
And I have sample WCF server written as console application. Here is the implementation:
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");
}
I'm not using xml configs.
Could you please help me ?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
看起来除非添加 .xml 配置文件,否则我无法使用此构造函数。
我最终使用了另一种以
CustomBinding
和EndpointAddress
作为参数的方法。Looks like I can't use this constructor unless I add .xml config file.
I ended up using another one which takes
CustomBinding
andEndpointAddress
as parameters.