1

Closed

partially trusted callers issue when running from network share

description

I'm getting an unhandled exception for NLog in a .Net 4.0 C# console application, when running the application from a network share or unc. I am using NLog 1.0.0.505 via SLF 1.0.0.0.
 
I found a work-around, but I don't understand why it works. What I did was remove the NLog configuration from the application config file, and moved it to a NLog.config file. With that configuration, the application loads, and logging works perfectly.
 
This is the exception I got before the work-around:
 
Unhandled Exception: System.Configuration.ConfigurationErrorsException: An error occurred creating the configuration section handler for nlog: That assembly does not allow partially trusted callers. (\bala01\home\SwDev\Compliance\Builds\SDMPNeovestAdapter\Current\DEV\SDMPNeovestAdapter.exe.Config line 5) ---> System.Security.SecurityException: That assembly does not allow partially trusted callers.
at System.Security.CodeAccessSecurityEngine.ThrowSecurityException(RuntimeAssembly asm, PermissionSet granted, PermissionSet refused, RuntimeMethodHandleInternal rmh, SecurityAction action, Object demand, IPermission permThatFailed)
at System.RuntimeTypeHandle.CreateInstance(RuntimeType type, Boolean publicOnly, Boolean noCheck, Boolean& canBeCached, RuntimeMethodHandleInternal& ctor, Boolean& bNeedSecurityCheck)
at System.RuntimeType.CreateInstanceSlow(Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache)
at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean skipVisibilityChecks, Boolean skipCheckThis, Boolean fillCache)
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at System.Configuration.TypeUtil.CreateInstanceWithReflectionPermission(Type type)
at System.Configuration.RuntimeConfigurationRecord.RuntimeConfigurationFactory.Init(RuntimeConfigurationRecord configRecord, FactoryRecord factoryRecord)
at System.Configuration.RuntimeConfigurationRecord.RuntimeConfigurationFactory.InitWithRestrictedPermissions(RuntimeConfigurationRecord configRecord, FactoryRecord factoryRecord)
at System.Configuration.RuntimeConfigurationRecord.CreateSectionFactory(FactoryRecord factoryRecord)
at System.Configuration.BaseConfigurationRecord.FindAndEnsureFactoryRecord(String configKey, Boolean& isRootDeclaredHere)
--- End of inner exception stack trace ---
at System.Configuration.BaseConfigurationRecord.FindAndEnsureFactoryRecord(String configKey, Boolean& isRootDeclaredHere)
at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
at System.Configuration.BaseConfigurationRecord.GetSection(String configKey)
at NLog.LogFactory.get_Configuration()
at NLog.LogFactory.GetLogger(LoggerCacheKey cacheKey)
at SLF.NLogFacade.NLogLoggerFactory.GetLogger(String name) in D:\Desktop\SLF\Source\Facades\SLF.NLogFacade\NLogLoggerFactory.cs:line 41
at Slf.LoggerService.GetLogger(String name) in D:\Desktop\SLF\Source\SLF\LoggerService.cs:line 155
at Application.Program.Main(String[] args) in C:\Users\rizzuto\p4root\SDMPNeovestAdapter\Application\Program.cs:line 61
Closed Oct 7, 2012 at 5:33 PM by Xharze
Moved to https://github.com/NLog/NLog/issues/108

comments