I'm writing this code in a Console Application targeting the .NET Framework 4 Client Profile.
this.container.AddFacility<LoggingFacility>(
f => f.LogUsing(LoggerImplementation.Log4net));
When it runs, it fails with a type conversion error.
Could not convert from 'Castle.Services.Logging.Log4netIntegration.Log4netFactory,Castle.Services.Logging.Log4netIntegration,Version=2.5.1.0,
Culture=neutral,PublicKeyToken=407dd0808d44fbdc'
to System.Type - Maybe type could not
be found
This is because the Castle.Services.Logging.log4netIntegration assembly is not copied to the output folder. As an runtime-only dependency, this doesn't break the build.
Looking at the build process, I found that it was not copying log4net or the Castle facility assembly because they depend on System.Web which is not available in the Client Profile. Changing to the standard profile means that this dependency is available and the facility can be added.
Why is this be done? What difference does it make that I am not targeting the client profile in a console application designed to be used as a scheduled task on a server?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…