Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Console App with Log4Net compiles in Debug but not in Release mode

I have a simple C#/4.0 console app that reference Log4Net 1.2.13.0 in VS2010.

In debug mode the app compiles and runs fine on my machine. However, as soon as I change to 'Release' I get the error

"Could not load file or assembly 'file:///C:\Users\mike\Documents\Visual Studio 2010\Projects\xxxx\yyyyy\log4net.dll' or one of its dependencies. Operation is not supported."

In the AssemblyInfo.cs I have added the line:

[assembly: log4net.Config.XmlConfigurator(Watch = true)]

According to the configuration mgr, but Debug and Release are set to use platform x86. This is also happening in another C# service application on my laptop, but I thought it easier if stick with getting it working here first.

The app.config file contains a section for:

<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />

Thanks in advance Mike

like image 705
mikcatta Avatar asked Nov 09 '22 18:11

mikcatta


1 Answers

Changing the type definition in the app.config to specify the fully qualified assembly name resolved the issue for me:

<section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler,log4net, Version=1.2.13.0, Culture=neutral, PublicKeyToken=669e0ddf0bb1aa2a" /> 
like image 185
mikcatta Avatar answered Nov 15 '22 07:11

mikcatta