我尝试在 Windows 服务任何机器上的 wcf 服务上使用远程 dll。但是 wcf 服务返回给我这个错误:
CommunicationException:从另一方接收到不安全或不正确安全的故障。有关故障代码和详细信息,请参阅内部 FaultException。
我的 wcf 服务运行良好。我还调用我的 wcf 服务调用 PROCESS.dll。我正在动态调用 wcf 服务:
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;
}
}
但出现上述错误。如何解决我的安全异常?