在 channelfactory WCF 上设置 ServiceBehavior Net.Pipe
Set ServiceBehavior on channelfactory WCF Net.Pipe
我正在托管来自表单应用程序的 Net.Pipe WCF 服务,该服务在服务器上运行,主要用于内部计算。为了改进这一点,我的任务是围绕该服务创建一个 Rest shell,以便它可以从服务器外部访问。我设法轻松连接到此服务,但是一旦我将它放到实时服务器上我的其余 shell 就无法再连接,我尝试调试它,但记录的主要错误消息是:
The server was unable to process the request due to an internal
error. For more information about the error, either turn on
IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute
or from the serviceDebug configuration behavior) on the server in
order to send the exception information back to the client, or turn on
tracing as per the Microsoft .NET Framework SDK documentation and
inspect the server trace logs.
问题是我从代码连接到此服务,但我不知道如何转换我连接到服务主机的方式,以便我可以添加服务行为或将行为添加到我的通道工厂。
NetNamedPipeBinding binding = new NetNamedPipeBinding(NetNamedPipeSecurityMode.None);
ServiceDebugBehavior behavior = new ServiceDebugBehavior { IncludeExceptionDetailInFaults = true };
EndpointAddress ep = new EndpointAddress("net.pipe://localhost/IPCService");
ChannelFactoryfactory = new ChannelFactory<RadanWrapper.IRadanContract>(binding);
// This line doesn't work
factory.Endpoint.EndpointBehaviors.Add(behavior as IServiceBehavior);
_channel = factory.CreateChannel(ep);
所以问题是:如何将行为连接到通道工厂,或者如何通过服务主机连接到此 net.pipe 服务。 (我还在研究第二个选项)
我发现了问题,我尝试将行为添加到其余 shell(连接端),而它应该添加到托管 [=15= 的表单应用程序(托管端) ] WCF
ServiceHost serviceHost = new ServiceHost(typeof(IPCService));
NetNamedPipeBinding binding = new NetNamedPipeBinding(NetNamedPipeSecurityMode.None);
// Create new behavior, remove any existing behaviors and add this new one.
var behavior = new ServiceDebugBehavior { IncludeExceptionDetailInFaults = true };
serviceHost.Description.Behaviors.Remove(typeof(ServiceDebugBehavior));
serviceHost.Description.Behaviors.Add(behavior);
serviceHost.AddServiceEndpoint(typeof(IPCService), binding, "net.pipe://localhost/IPCService");
serviceHost.Open();
幸好我现在收到一条实际工作的错误消息,事实证明我缺少一个特定的 dll,它在部署到服务器期间没有正确构建。
我正在托管来自表单应用程序的 Net.Pipe WCF 服务,该服务在服务器上运行,主要用于内部计算。为了改进这一点,我的任务是围绕该服务创建一个 Rest shell,以便它可以从服务器外部访问。我设法轻松连接到此服务,但是一旦我将它放到实时服务器上我的其余 shell 就无法再连接,我尝试调试它,但记录的主要错误消息是:
The server was unable to process the request due to an internal error. For more information about the error, either turn on IncludeExceptionDetailInFaults (either from ServiceBehaviorAttribute or from the serviceDebug configuration behavior) on the server in order to send the exception information back to the client, or turn on tracing as per the Microsoft .NET Framework SDK documentation and inspect the server trace logs.
问题是我从代码连接到此服务,但我不知道如何转换我连接到服务主机的方式,以便我可以添加服务行为或将行为添加到我的通道工厂。
NetNamedPipeBinding binding = new NetNamedPipeBinding(NetNamedPipeSecurityMode.None);
ServiceDebugBehavior behavior = new ServiceDebugBehavior { IncludeExceptionDetailInFaults = true };
EndpointAddress ep = new EndpointAddress("net.pipe://localhost/IPCService");
ChannelFactoryfactory = new ChannelFactory<RadanWrapper.IRadanContract>(binding);
// This line doesn't work
factory.Endpoint.EndpointBehaviors.Add(behavior as IServiceBehavior);
_channel = factory.CreateChannel(ep);
所以问题是:如何将行为连接到通道工厂,或者如何通过服务主机连接到此 net.pipe 服务。 (我还在研究第二个选项)
我发现了问题,我尝试将行为添加到其余 shell(连接端),而它应该添加到托管 [=15= 的表单应用程序(托管端) ] WCF
ServiceHost serviceHost = new ServiceHost(typeof(IPCService));
NetNamedPipeBinding binding = new NetNamedPipeBinding(NetNamedPipeSecurityMode.None);
// Create new behavior, remove any existing behaviors and add this new one.
var behavior = new ServiceDebugBehavior { IncludeExceptionDetailInFaults = true };
serviceHost.Description.Behaviors.Remove(typeof(ServiceDebugBehavior));
serviceHost.Description.Behaviors.Add(behavior);
serviceHost.AddServiceEndpoint(typeof(IPCService), binding, "net.pipe://localhost/IPCService");
serviceHost.Open();
幸好我现在收到一条实际工作的错误消息,事实证明我缺少一个特定的 dll,它在部署到服务器期间没有正确构建。