C# 如何解决;未担保或担保不正确的故障”;wcf通信中的异常?
我尝试在windows service任意计算机中通过wcf服务使用远程dll。但wcf服务返回此错误: 通信异常:从另一方接收到不安全或安全性不正确的故障。有关故障代码和详细信息,请参见内部故障异常。 我的wcf服务运行良好。我还调用了我的wcf服务,调用了PROCESS.dll。我正在动态调用wcf服务:C# 如何解决;未担保或担保不正确的故障”;wcf通信中的异常?,c#,wcf,web-services,windows-services,security,C#,Wcf,Web Services,Windows Services,Security,我尝试在windows service任意计算机中通过wcf服务使用远程dll。但wcf服务返回此错误: 通信异常:从另一方接收到不安全或安全性不正确的故障。有关故障代码和详细信息,请参见内部故障异常。 我的wcf服务运行良好。我还调用了我的wcf服务,调用了PROCESS.dll。我正在动态调用wcf服务: public static ApplicationHostServiceClient CreateApplicationHostService() {
public static ApplicationHostServiceClient CreateApplicationHostService()
{
try
{
int maxDifference = 300;
WSHttpBinding binding = new WSHttpBinding();
binding.MaxReceivedMessageSize = int.MaxValue;
binding.MaxBufferPoolSize = int.MaxValue;
binding.ReaderQuotas.MaxArrayLength = int.MaxValue;
CustomBinding myCustomBinding = new CustomBinding(binding); //CreateMultiFactorAuthenticationBinding(binding);
// Set the maxClockSkew
var security = myCustomBinding.Elements.Find();
security.LocalClientSettings.MaxClockSkew = TimeSpan.FromMinutes(maxDifference);
security.LocalServiceSettings.MaxClockSkew = TimeSpan.FromMinutes(maxDifference);
// Set the maxClockSkew
var secureTokenParams = (SecureConversationSecurityTokenParameters)security.ProtectionTokenParameters;
var bootstrap = secureTokenParams.BootstrapSecurityBindingElement;
bootstrap.LocalClientSettings.MaxClockSkew = TimeSpan.FromMinutes(maxDifference);
bootstrap.LocalServiceSettings.MaxClockSkew = TimeSpan.FromMinutes(maxDifference);
// Update the binding of the endpoint
// service.Description.Endpoints[0].Binding = myCustomBinding;
EndpointAddress endpoint = new EndpointAddress(new Uri(ProcessApplication.Serverparameters.BaseServiceHost + "/Service/ApplicationHostService.svc"));
ApplicationHostServiceClient ser = new ApplicationHostServiceClient(myCustomBinding, endpoint);
return ser;
}
catch (Exception exc)
{
ProcessApplication.Application.OnError("CreateApplicationHostService is not succeeded.", "CreateApplicationHostService", exc);
return null;
}
}
但出现了上述错误。如何解决我的安全异常?maxDifference的值是多少?能否尝试低于10的maxDifference?在客户端和服务器上都启用wcf跟踪以查看更多信息