Unfortunately NLog was not designed or tested to run in partial trust so default logging options require P/Invoke which causes issues.
If you can re-compile NLog for your installation, you should be able to work-around this particular issue by opening src\NLog\Internal\FileAppenders\BaseFileAppender.cs file and commenting out or removing the lines in #if/#endif region.
#if !NETCF
if (PlatformDetector.IsCurrentOSCompatibleWith(RuntimeOS.WindowsNT) ||
PlatformDetector.IsCurrentOSCompatibleWith(RuntimeOS.Windows))
{
return WindowsCreateFile(FileName, allowConcurrentWrite);
}
#endif
return new FileStream(FileName,
FileMode.Append,
FileAccess.Write,
fileShare,
_createParameters.BufferSize);
I don't have a way of verifying this fix, so please let me know if it works for you.