MTK Android Based Phone IMEI Write Tool, DirecTV Now Launch Will Include Zero Rated Bandwidth on the Mobile Network, video entertainment product with a heavy mobile, Smartphone Apps Drive Content Usage, It will not surprise you that smartphones now are the ways most people interact with the Internet, Social Networking Web Server via Arbitrary Code Execution, Released Add New Method FOR Reset FRP Samsung

Sunday, December 13, 2015

All New How to debug a Windows Service written in C# flawlessly

All New How to debug a Windows Service written in C# flawlessly - do you know that every day there are new gadgets that are created with new advantages to simplify your life, on the blog Gadget Center we will discuss about the latest gadgets and gadgets that have long ranging from speck and price, now we will discuss about All New How to debug a Windows Service written in C# flawlessly we have collected a lot of news to make this article to be really useful for you, please see.

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

You can also see our article on:


All New 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



article titled All New How to debug a Windows Service written in C# flawlessly has been completed in the discussion

hopefully information about All New How to debug a Windows Service written in C# flawlessly can provide benefits for you in determining the gadget to suit your needs so much easier in living everyday life.

you just read the article entitled All New How to debug a Windows Service written in C# flawlessly if you feel this information is useful for you and want to bookmark it or want to share it please use link https://mjoaobrum.blogspot.com/2015/12/all-new-how-to-debug-windows-service.html.

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

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

0 comments:

Post a Comment