This blog displays information about the latest android smartphone, price and specs as well as information applikaksi game that appeals to you, here are also a lot of software that you can download

Minggu, 13 Desember 2015

How to debug a Windows Service written in C# flawlessly

How to debug a Windows Service written in C# flawlessly - is looking for information, and in this blog Android Gadgets we have been providing very complete information from various sources that reliable, well we'll talk about the How to debug a Windows Service written in C# flawlessly as you need, please si read to completion.

Articles : How to debug a Windows Service written in C# flawlessly
full Link : How to debug a Windows Service written in C# flawlessly
Article c#, Article featured, Article programming, Article Windows,

You can also see our article on:


How to debug a Windows Service written in C# flawlessly

Hi guys,

I know its been frustrating to install and uninstall and stop and start ,each and every time you have modified your windows service.



If you tried to directly Run or Press F5 ,then this will be the result from Visual Studio.

How to debug a C# written windows service

  • After creating a C# -> Windows Service project.
  • Double click "Program.cs" from the 'Solution explorer' from in VS.
  • Now change the code in function main() to the code mentioned below.
static void Main()
{
#if(!DEBUG)
ServiceBase[] ServicesToRun;
ServicesToRun = new ServiceBase[]
new Service1() //Replace this with your service class name
ServiceBase.Run(ServicesToRun);
#else
Service1 myServ = new Service1(); //Replace this with your service class name
myServ.main();//This will invoke the function which contains the code you should put in OnStart when the real service runs.Just define a function called main and copy the code that you had put in OnStart. 

#endif
}

Explanation of the above code

If the Runtime configuration is set to "Debug" then the service will run as an ordinary Console application.You may set break points and debug.


If the Runtime configuration is set to anything else ,other than "Debug" then it will run as a normal service which responds to installutil and net start or stop commands.


Hope this helped you a lot in your programming career.Any comments, feel free to use the comment box below


Articles How to debug a Windows Service written in C# flawlessly has been discussed

A few gadget information How to debug a Windows Service written in C# flawlessly, hopefully can provide benefits to you all.

You're reading an article How to debug a Windows Service written in C# flawlessly and this article url is https://androidtabletgadgets.blogspot.com/2015/12/how-to-debug-windows-service-written-in.html?m=1 you can bookmark , Hopefully this article could be useful and do not forget to always to this blog to find information on gadget.

Tag : , , , ,

0 komentar:

Posting Komentar