Windows服务开发异常问题处理汇总一

.Net技术 码拜 5年前 (2019-09-25) 2637次浏览 0个评论

1、不可访问的日志: Security, State

右键单击“以管理员身份运行”。另外,windows服务中使用了log4net记录日志,应用程序执行目录缺少日志的配置文件 log4net.config,拷贝即可。

2、在“安装”阶段发生异常。System.ComponentModel.Win32Exception: 指定的服务已标记为删除。

关闭服务窗口Windows服务开发异常问题处理汇总一

3、System.ArgumentException: ServiceHost 仅支持类服务类型。

错误代码:ServiceHost _host = new ServiceHost(typeof(FileHandler.WinSvc.Service.IGenerateService));

改为使用类来初始化:ServiceHost _host = new ServiceHost(typeof(FileHandler.WinSvc.Service.GenerateService));

4、System.InvalidOperationException:“绑定验证失败,因为绑定的 MsmqAuthenticationMode 属性被设置为 WindowsDomain 但在安装 MSMQ 时 Active Directory 集成被禁用了。无法打开通道工厂或服务主机。”

<system.serviceModel>
<bindings>
<netMsmqBinding>
<binding name=”msmq” exactlyOnce=”true”>
<security mode=”None”></security>
</binding>
</netMsmqBinding>
</bindings>
<client>
<endpoint name=”PdfGenerateServiceClient”
address=”net.msmq://localhost/private/pdfgeneratelist” bindingConfiguration=”msmq”
binding=”netMsmqBinding”
contract=”PISFileHandler.WinSvc.Service.IPdfGenerateService”></endpoint>
</client>
</system.serviceModel>


CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明Windows服务开发异常问题处理汇总一
喜欢 (1)
[1034331897@qq.com]
分享 (0)

文章评论已关闭!