Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/332.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何解决;未担保或担保不正确的故障”;wcf通信中的异常?_C#_Wcf_Web Services_Windows Services_Security - Fatal编程技术网

C# 如何解决;未担保或担保不正确的故障”;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() {

我尝试在windows service任意计算机中通过wcf服务使用远程dll。但wcf服务返回此错误:

通信异常:从另一方接收到不安全或安全性不正确的故障。有关故障代码和详细信息,请参见内部故障异常。

我的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;
            }

        }

但出现了上述错误。如何解决我的安全异常?

maxDifference的值是多少?能否尝试低于10的maxDifference?在客户端和服务器上都启用wcf跟踪以查看更多信息