Samsung Galaxy Note, 4G LTE Plans, Transfer Photos Videos from iPhone to Samsung, Network Performance, Mobile Accounts, Furious Gold SPD TooL, Latest Version Full Setup

Info How to debug a Windows Service written in C# flawlessly

Info How to debug a Windows Service written in C# flawlessly - this blog we have built from a few years ago and already very much information about gadgets that we convey and a lot of blog visitors New Blog Techno News who are satisfied with the information, we will always try to update the latest information for you, first about Info How to debug a Windows Service written in C# flawlessly many already we collect data to make this article so you do not miss the news, please see:

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

You can also see our article on:


Info 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 Info How to debug a Windows Service written in C# flawlessly finished in discussion

hopefully the information we convey about Info How to debug a Windows Service written in C# flawlessly can benefit you in getting new knowledge about technology,

you just finished reading the information Info How to debug a Windows Service written in C# flawlessly we hope this informmation can answer the question you submit to googlle, if you want to bookmark or share please use link https://moymoycikukecik.blogspot.com/2015/12/info-how-to-debug-windows-service.html and do not forget to always visit this blog to get the latest information every day.

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

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

0 komentar:

Posting Komentar