How to Debug a WCF Service Hosted in Windows Service

1.Open the Service1.cs file and add two more public methods in the same class, which basically calls the OnStart() and OnStop() methods internally:

      
        public void OnDebugMode_Start()
        {
            OnStart(null);
        }
        public void OnDebugMode_Stop()
        {
            OnStop();
        }

1.Open the Program.cs and modify main

        static void Main()
        {
            #if (!DEBUG)
            ServiceBase[] ServicesToRun;
            ServicesToRun = new ServiceBase[] 
			{ 
				new Service1() 
			};
            ServiceBase.Run(ServicesToRun);
            #else
            var service = new Service1();
            service.OnDebugMode_Start();
            System.Threading.Thread.Sleep(System.Threading.Timeout.Infinite);
            service.OnDebugMode_Stop();
            #endif
        }

source How to Debug a WCF Service Hosted in Windows Service