1. add new project by Right clicking on Solution
2. go to Windows tab
3. select Console Application then give some name for selfhosting name: e.g. CalCAreaWcf then click ok.
4. Add System.ServiceModel as reference and also Add WCF Service as a Project reference
5. add using System.ServiceModel; on the program.cs
6. copy App.Config file from Wcf Service folder to this folder
7. Write some code in program.cs for hosting service
you can write like this:
namespace CalcAreaWcf
{
class Program
{
static void Main(string[] args)
{
try{
ServiceHost CalculatingAreaService = new ServiceHost(typeof(CalcAreaWcfService));
CalculatingAreaService.Open();
Console.WriteLine("Cheers!!! Service is Running, Press Enter to close Serive");
Console.ReadLine();
CalculatingAreaService.Close();
}
catch(Exception e){
Console.WriteLine("Problem occur");
Console.WriteLine("Error {0}", e);
Console.ReadLine();
}
}
}
}
Now everything is done. You need to build the hostingservice by Rclicking on Hosting file.
I thing, now service is build u can go and see it from Command prompt of respective project location
projectfile\bin\debug\CalculatingAreaService.exe
Hurrey! Service is Running....
No comments:
Post a Comment