【发布时间】:2011-07-25 05:37:20
【问题描述】:
我已经创建了一个 Windows 服务。
当我在本地计算机上安装服务后尝试启动服务时,出现错误。
我的其他 windows 服务运行良好,只有这个特定的服务给出了这个错误,所以问题与 windows 无关,而与我的服务有关。
可能出了什么问题?
这是我的 Windows 服务:
namespace TempWindowService
{
public partial class Service1 : ServiceBase
{
System.Threading.Thread _thread;
public Service1()
{
InitializeComponent();
}
// System.Timers.Timer tm = new System.Timers.Timer(10000);
protected override void OnStart(string[] args)
{
TempWindowService.MyServ.MyServSoapClient newService = new TempWindowService.MyServ.MyServSoapClient();
//newService.BatchProcess();
_thread = new Thread(new ThreadStart(newService.BatchProcess));
_thread.Start();
// tm.Interval = 1000;
//tm.Elapsed += new ElapsedEventHandler(TimerElapsedEvent);
// tm.AutoReset = true;
// tm.Enabled = true;
}
public void StartNew()
{
TempWindowService.MyServ.MyServSoapClient newService = new TempWindowService.MyServ.MyServSoapClient();
newService.BatchProcess();
}
private static void TimerElapsedEvent(object source, ElapsedEventArgs e)
{
}
protected override void OnStop()
{
}
}
}
我通过添加服务引用从 windows 服务调用 web 服务
这就是错误在 EventViewer 中显示的内容
Service cannot be started. System.InvalidOperationException: An endpoint configuration section for contract 'MyServ.MyServSoap' could not be loaded because more than one endpoint configuration for that contract was found. Please indicate the preferred endpoint configuration section by name.
at System.ServiceModel.Description.ConfigLoader.LookupChannel(String configurationName, String contractName, Boolean wildcard)
可能出了什么问题?
【问题讨论】:
-
检查事件查看器中是否记录了任何错误。
-
如果服务在您能够附加调试器之前停止,请查看this question on how to break 的答案。
-
@Sachin 和@Ole_Brun:感谢您的意见。我已将 eventViewer 错误添加到我的问题中。请检查一下,请告诉我可能出了什么问题?
标签: .net .net-3.5 windows-services service