Innaz Review, Samsung Galaxy, price and specifications, Flash Android, Games For Your Apple, Jailbreak Tool For iOS, IMEI Unlock Method

Minggu, 13 Desember 2015

How to debug a Windows Service written in C# flawlessly

How to debug a Windows Service written in C# flawlessly - In the past, when I started to start blogging, many thoughts disturbed me. I want to have a blog with a nice and interesting look. I am constantly looking for basic tutorials from some web and blogs on the internet. And thankfully, one by one I started to do it, and of course have to go through some confusion process first, but the most important of a blog that is content, yes on the blog Innaz Review we will discuss a lot of information about gadgets that are very in need by you, now we will discuss first about How to debug a Windows Service written in C# flawlessly please refer to the information we will convey until completion:

Articles : How to debug a Windows Service written in C# flawlessly
full Link : How to debug a Windows Service written in C# flawlessly

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



so much information How to debug a Windows Service written in C# flawlessly

hopefully How to debug a Windows Service written in C# flawlessly information can provide benefits for you in determining the gadgets that fit your needs in daily life.

you just read How to debug a Windows Service written in C# flawlessly if you feel this information is useful and want to bookmark or share it please use link https://innaz2.blogspot.com/2015/12/how-to-debug-windows-service-written-in.html if you want more information please search on other pages this blog.

Tag :
Share on Facebook
Share on Twitter
Share on Google+
Tags :

Related : How to debug a Windows Service written in C# flawlessly

0 komentar:

Posting Komentar