I created a new solution.
Added my test project (command.handler.tests)
Added a Windows Service project (command.handler.service)
Added a class library project for all my code to sit in (command.handler)
As this was an empty stub to just deploy as a first pass I got the command.handler.service to call the command.handler every time it started and stopped. Added the project reference. Compiled. Success.
I then added some logic into the command.handler to simply log when the service had been started and stopped:
private static readonly ILog _log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public void Start()
{
_log.Info("Service started...");
}
public void Stop()
{
_log.Info("Service stopped.");
}
Went to compile and BOOM! it blew up in my face. ) : command.handler.service could not find the class in command.handler using log4net.
(are you missing a using directive or an assembly reference?)
No. No Visual Studio I am not missing reference.
This happened right at the end of the day. After much hair pulling, staying late, leaving work to go on an aborted street skate (due to equipment failure) I returned to this problem and did what I should have done in the first place. Turned to google:
“log4net are you missing and assembly reference”
and I came across this lovely post by Tony Mocella.
Basically what’s happened is that the target framework for my Windows Service project (command.handler.service) was set to .NET Framework 4 Client Profile. In the project properties I changed it to .NET Framework 4 and job was a good un.
So moral of the story, if it doesn’t compile check your target frameworks. Also #googleisyourfriend
::headdesk::
This got me today too. Thanks for sharing the solution!
Thanks Mate – this saved me hours today.
Mate You saved me. Thanks