Bonjour,
j'ai implémenter un service windows, je voudrais savoir comment je peux le debugger pour situer mon problème???
Merci,
xav
Version imprimable
Bonjour,
j'ai implémenter un service windows, je voudrais savoir comment je peux le debugger pour situer mon problème???
Merci,
xav
On ne peut pas débugguer un service Windows, il faut soit ajouter un projet Winform, soit ajouter une Form de démarrage dans ton projet Service que tu lanceras dans ta liste de Thread
Par exemple :
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46 //Dans la classe du service : #if DEBUG private static MyService m_serv = new MyService(); #endif static void Main() { #if !DEBUG System.ServiceProcess.ServiceBase[] ServicesToRun; // More than one user Service may run within the same process. To add // another service to this process, change the following line to // create a second service object. For example, // // ServicesToRun = New System.ServiceProcess.ServiceBase[] {new MyService(), new MySecondUserService()}; // ServicesToRun = new System.ServiceProcess.ServiceBase[] { new MyService() }; System.ServiceProcess.ServiceBase.Run(ServicesToRun); #else m_serv.OnStart (new string[0]); System.Windows.Forms.Application.ApplicationExit += new EventHandler(Application_ApplicationExit); System.Windows.Forms.Application.Run (new dbgForm()); #endif } #if DEBUG private static void Application_ApplicationExit( object sender, EventArgs e) { m_serv.OnStop(); } #endif //Dans un fichier à part : #if DEBUG internal class dbgForm : System.Windows.Forms.Form { public dbgForm () { this.Width = 400; this.Height = 20; this.Text = "MyService (Debug Mode)"; this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.Fixed3D; } } #endif
Tu peux débogguer avec Visual Studio, jette un oeil la dessus (en anglais)
http://msdn.microsoft.com/en-us/libr...b3(VS.80).aspx