NLog2 API implementation | .Net4 | GAC | 64bit

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
Report Content as Inappropriate

NLog2 API implementation | .Net4 | GAC | 64bit

The below post is what I was experiencing and I have done a number of tests since writing it. The way to fix the problem is to copy the appropriate released NLog2 dll into the same directory as the solution. I need to do a lot more testing but this could cause serious issues when it comes to deployment.

I also note that the file version is updated however the product version number is not. I have only come across this once before and that is with VistaDB. They advised me they don't update the product version number as it would break a number of installations. In my case, not updating the product version number (in NLog.dll's case it should now be seems to break my installation.

AFAIK, which dll is the newer is determined from the product version and not the file version.

------------ The following is what was going to be my original post ----------------------------------------
Ever since versions after beta version 2 of NLog2 I have encountered exceptions thrown by the following code:

      FileTarget fileTarget = new FileTarget();
      fileTarget.Layout = "${longdate} ${machineName} ${callsite} ${message} ${exception:format=tostring}";
      fileTarget.FileName = "NLTest.log";
      fileTarget.KeepFileOpen = false;
      fileTarget.Encoding = Encoding.Default;

      LoggingConfiguration config = new LoggingConfiguration();
      LoggingRule rule1 = new LoggingRule("*", LogLevel.Debug, fileTarget);
      config.AddTarget("target", fileTarget);

      LogManager.Configuration = config;  <------------------------------- Error here

The exception is
_innerException {"Unable to cast object of type 'NLog.Layouts.SimpleLayout' to type 'NLog.Layouts.LayoutWithHeaderAndFooter'."} System.Exception {System.InvalidCastException}

If I use an xml configuration file I don't experience any problems but I need to use the API.

The compiled test project runs on an 32bit system (at least WinXP) but fails on an 64bit system. My dev machine is a 64bit Win7 machine. I've checked my VS2010 project and have set the Platform target to Any CPU. Setting it to x92 or x64 makes no difference.

I have been unable to get any assistance apart from ".. it works on my machine", to date and am hoping someone has come across this issue and has found a workaround, or at least pointed out what I am doing wrong.

A test project that demonstrates the error is attached:

My frustration level is off the scale at this stage so even some sympathy comments might help cheer me up