I have a windows service that I have successfully installed using installutil but when I run it I get an error saying that the service failed to start because it failed to respond in a timely fashion. In the Event Viewer, I can see this error.
Application: AuctionControl.Service.exe
Framework Version: v4.0.30319
Description: The process was terminated due to an unhandled exception.
Exception Info: Microsoft.Practices.Unity.ResolutionFailedException
Stack:
at Microsoft.Practices.Unity.UnityContainer.DoBuildUp(System.Type, System.Object, System.String, System.Collections.Generic.IEnumerable`1<Microsoft.Practices.Unity.ResolverOverride>)
at Microsoft.Practices.Unity.UnityContainer.Resolve(System.Type, System.String, Microsoft.Practices.Unity.ResolverOverride[])
at Microsoft.Practices.Unity.UnityContainerExtensions.Resolve[[System.__Canon, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]](Microsoft.Practices.Unity.IUnityContainer, Microsoft.Practices.Unity.ResolverOverride[])
at AuctionControl.Service.Service1..ctor()
at AuctionControl.Service.Program.Main()
My code is below
using System.ServiceProcess;
using Microsoft.Practices.Unity;
namespace AuctionControl.Service
{
public partial class Service1 : ServiceBase
{
#region Constructor(s)
public Service1()
{
InitializeComponent();
_container = new UnityContainer();
_auctionControl = _container.Resolve<Services.Engine.AuctionControl>();
}
#endregion
#region Fields
private readonly Services.Engine.AuctionControl _auctionControl;
private readonly UnityContainer _container;
#endregion
protected override void OnStart(string[] args)
{
_auctionControl.StartAuctionControl();
}
protected override void OnStop()
{
_auctionControl.StopAuctionControl();
}
}
}