|
-
Mar 31st, 2011, 09:38 AM
#1
Thread Starter
Fanatic Member
[RESOLVED] running a wcf process inside a windows service.
Hi All,
My app started off as a standard web app, but becuase the client is really initiating a batch process that potentially may run for a long time, I pulled the long running process out and made it a WCF Service Library. However, it occured to me that the app would still suffer time out issues due to IIS recycling etc. SO to negate this I've attempted to write a windows service that wraps the WCF Process. I've followed many examples from the web on setting the Windows service up, but when I try to run the service it stops straight away.
In the Windows Service in the Default program.cs file, I've not made any changes to the default code.:
Code:
static void Main()
{
ServiceBase[] ServicesToRun;
ServicesToRun = new ServiceBase[]
{
new IRSBorderauxService()
};
ServiceBase.Run(ServicesToRun);
}
I've made a reference to the WCF dll that was generated from the build of my WCF Project.
in the IRSBorderauxService I have made a reference to the service and declared a ServiceHost.
Code:
using wcfBorderauxIRSService;
namespace IRSBorderauxService
{
public partial class IRSBorderauxService : ServiceBase
{
ServiceHost sHost;
public IRSBorderauxService()
{
InitializeComponent();
}
protected override void OnStart(string[] args)
{
sHost = new ServiceHost(typeof(wcfBorderauxIRSService.IRSService));
sHost.Open();
}
protected override void OnStop()
{
sHost.Close();
}
}
}
I have also created an App.config file based on the WCF projects app.config.
I have also introduced a project listener and against the ServiceInstaller have set the Start Type to Automatic and set the serviceName.
If I attempt to step the code, it gets to the last line of program.cs Main
Code:
ServiceBase.Run(ServicesToRun);
and error's with : Cannot start service from the command line or debugger. A Windows Service must first be installed (using installutil.exe)....
I Created a setup project in the solution and run the install, I can see the Machines Services from the control panel.
Can anybody tell me what I have missed.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|