2011-01-22 52 views
3

我使用c#。這時我使用Windows 7.我的問​​題是;當我運行我的代碼時, 這給我錯誤等193:0xc1錯誤,服務啓動但停止後,1053服務錯誤。 這是我的代碼。C中的Windows服務錯誤#

public RupdaterService() 
    { 
     InitializeComponent(); 
     this.timer1.Elapsed += new System.Timers.ElapsedEventHandler(this.timer1_Elapsed); 
    } 
     protected override void OnStart (string[] args) 
    { 
     timer1.Enabled=true; 
     this.DBEntry("Service Started"); 
    } 
     protected override void OnStop() 
    {    
     this.timer1.Enabled = false; 
     this.DBEntry("Service Stopped"); 
    } 

    private void timer1_Elapsed(object sender,System.Timers.ElapsedEventArgs e) 
    { 

     this.DBEntry("Service Running"); 
     } 


Here is my App.Config. 

<?xml version="1.0" encoding="utf-8" ?> 

<configuration> 

<configSections> 

    <sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c5***9" > 
     <section name="HedefliRUpdater.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5***9" requirePermission="false" /> 
    </sectionGroup> 
</configSections> 

<system.serviceModel> 

</system.serviceModel> 

<applicationSettings> 
    <HedefliRUpdater.Properties.Settings> 
     <setting name="HedefliRUpdater_srvHedefli_wsrvHermesHedefliMesaj" 
      serializeAs="String"> 
      <value>http://***.com/hedefli/srvHedefli.asmx</value> 
     </setting> 
    </HedefliRUpdater.Properties.Settings> 
</applicationSettings> 

由於提前,

+1

在EventViewer中檢查應用程序事件日誌。 DBEntry方法調用中最可能的一些例外。 – 2011-01-22 16:02:17

+0

那麼除了調試,我應該怎麼做? – Arbelac 2011-01-22 16:33:21

回答

2

有些事情要檢查。這些發生在我身上,離開了我的頭頂:

  1. 事件日誌中是否有任何內容?他們有時可以給你一個線索。

  2. 事件日誌是否已滿?如果Windows無法寫入,它將不會啓動該服務。嘗試清除應用程序事件日誌並查看它是否啓動。

  3. .config文件中是否存在任何語法錯誤?我們曾經有一個問題,與把一個<端點>標籤的< /配置>

  4. 末它看起來像你寫入數據庫後.msi安裝。運行該服務的用戶是否可以訪問該數據庫?

  5. 嘗試在您的OnStart()的開頭放置Debugger.Break()以提示Windows在啓動時連接Visual Studio實例。至少,它會告訴你,如果故障發生在它到達OnStart之前或之後。

  6. 您是否有多個<端點>在app.config/web.config文件中指定的匹配相同的合同?嘗試刪除多餘的端點

0

我也有類似的問題,發現下面的鏈接有用: http://support.microsoft.com/default.aspx?scid=kb;en-us;Q325680

在我的情況下的exe是在C:\文件ANS設置....和有一個名爲C:\ Documents的文件。刪除這個文件有幫助,但我仍然在尋找一種方法來解決這個編程問題。