我在託管在IIS和Windows Server 2003上的ASP.NET應用程序中使用NLog。當我在開發機器上運行代碼時,一切正常。但是當我將代碼部署到服務器時。 NLog目標的初始化將導致安全異常:初始化Nlog事件日誌目標時的安全異常
安全異常 描述:應用程序試圖執行安全策略不允許的操作。要授予此應用程序所需的權限,請聯繫您的系統管理員或更改配置文件中的應用程序信任級別。
Exception Details: System.Security.SecurityException: Requested registry access is not allowed.
源錯誤:
在當前web請求的執行過程中生成未處理的異常。關於異常的來源和位置的信息可以使用下面的異常堆棧跟蹤來標識。
堆棧跟蹤:
[SecurityException: Requested registry access is not allowed.]
System.ThrowHelper.ThrowSecurityException(ExceptionResource resource) +51
Microsoft.Win32.RegistryKey.OpenSubKey(String name, Boolean writable) +7462217
System.Diagnostics.EventLog.CreateEventSource(EventSourceCreationData sourceData) +366
NLog.Targets.EventLogTarget.CreateEventSourceIfNeeded() +637 NLog.Targets.EventLogTarget.InitializeTarget() +40 NLog.Targets.Target.Initialize() +264 NLog.Config.LoggingConfiguration.InitializeAll() +233
有誰的時候我應該怎樣才能做到,給應用程序適當的權限?謝謝!
有沒有人有同樣的問題? – Roy 2010-08-18 05:14:03