ServiceHost是否不分离端点?无法从故障状态中恢复

编程入门 行业动态 更新时间:2024-10-11 17:27:54
本文介绍了ServiceHost是否不分离端点?无法从故障状态中恢复的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我的服务启动代码:

public void Start() { try { var certificate = new X509Certificate2(certpath, ""); String uri = "net.tcp://" + WCFAddress + "/CommunicationService"; Uri baseaddress = new Uri(uri); if (WebService != null) { if (WebService.State!= CommunicationState.Faulted) WebService.Close(); else WebService.Abort(); WebService = null; } WebService = new ServiceHost(MessageProvider, baseaddress); WebService.Credentials.ServiceCertificate.Certificate = certificate; WebService.Credentials.ClientCertificate.Authentication.CertificateValidationMode = X509CertificateValidationMode.None; NetTcpBinding binding = new NetTcpBinding(); binding.Security.Mode = SecurityMode.Message; binding.Security.Message.ClientCredentialType = MessageCredentialType.Certificate; binding.Security.Transport.ClientCredentialType = TcpClientCredentialType.Certificate; WebService.AddServiceEndpoint(typeof(IMessageService), binding, baseaddress); WebService.Open(); } catch (Exception e) { //Exception handling } }

推荐答案

您好,您是说您正在调用一个不会退出的服务,该服务失败了,后来您调用了一个能够正常工作的服务但它也会失败吗?这应该不会发生...您能否确保在第一次调用正确的服务时也没有例外 被抛出? Hello, do you mean you're calling a service that doesn't exit, which fails, later you call a service that used to work fine but it fails as well?This should not happen... Can you make sure the first time when you call the correct service, no exception is thrown?

更多推荐

ServiceHost是否不分离端点?无法从故障状态中恢复

本文发布于:2023-11-13 04:45:41,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1583469.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:故障   状态   ServiceHost

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!