我創建了一個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服務的WebService
這是在事件查看器
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)
什麼顯示錯誤
什麼可能是錯的?
檢查是否有記錄的任何錯誤事件查看器。 – 2011-03-29 12:02:44
如果該服務在能夠附加調試器之前停止,請查看[this]的回答(http://stackoverflow.com/questions/5266971/null-reference-exception/5267016#5267016)打破。 – 2011-03-29 12:07:41
@Sachin和@Ole_Brun:感謝您的輸入。我已將eventViewer錯誤添加到我的問題中。請檢查一下,請告訴我可能會出現什麼問題? – 2011-03-29 12:50:19