作者热门文章
- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我们在带有自定义配置部分的测试环境中遇到了一个奇怪的错误。
这适用于在开发和测试环境中运行在带有 SQL Server 2008 的 Enterprise Server 2008 r2 64 位上的 Windows 服务。
此部分配置我们的共享代码库,以便在处理错误时向感兴趣的各方发送电子邮件,并使用如下代码发布:
catch(Exception ex)
{
ExceptionManager.Publish(ex);
}
错误细节(完整的细节 - 更改名称以保护无辜者)
4 <configSections>
5 <section name="exceptionManagement"
6 type="Company.Shared.ExceptionManagement.ExceptionManagerSectionHandler, Company.Shared" />
7 </configSections>
8 <exceptionManagement>
9 <publisher assembly="Company.Shared" type="Company.Shared.ExceptionManagement.DefaultPublisher"
10 logName="CPODSOracleDataExchange" applicationName="CPODSOracleDataExchange Service" />
11 <publisher assembly="Company.Shared" type="Company.Shared.ExceptionManagement.ExceptionManagerSMTPPublisher"
12 from="CPODSOracleDataExchangeService@Company.com"
13 defaultRecipients="dev1@Company.com,dev2@Company.com"
14 applicationName="CPODSOracleDataExchange Service" />
15 </exceptionManagement>
1) Exception Information
*********************************************
Exception Type: System.Configuration.ConfigurationErrorsException
Message: An error occurred creating the configuration section handler for exceptionManagement: Request failed. (E:\CITApps\Services\CPODS.OracleDataExchangeService\Company.CPODS.OracleDataExchangeService.exe.Config line 5)
BareMessage: An error occurred creating the configuration section handler for exceptionManagement: Request failed.
Filename: E:\CITApps\Services\CPODS.OracleDataExchangeService\Company.CPODS.OracleDataExchangeService.exe.Config
Line: 5
Errors: System.Configuration.ConfigurationException[]
Data: System.Collections.ListDictionaryInternal
TargetSite: System.Configuration.FactoryRecord FindAndEnsureFactoryRecord(System.String, Boolean ByRef)
HelpLink: NULL
Source: System.Configuration
StackTrace Information
*********************************************
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 Company.Shared.ExceptionManagement.ExceptionManager.Publish(Exception exception, NameValueCollection additionalInfo)
2) Exception Information
*********************************************
Exception Type: System.Security.SecurityException
Action: Demand
PermissionType: System.Security.PermissionSet
FirstPermissionThatFailed: NULL
PermissionState: <PermissionSet class="System.Security.PermissionSet"
version="1"
Unrestricted="true"/>
Demanded: <PermissionSet class="System.Security.PermissionSet"
version="1"
Unrestricted="true"/>
GrantedSet:
RefusedSet:
DenySetInstance: NULL
PermitOnlySetInstance: <PermissionSet class="System.Security.PermissionSet"
version="1">
<IPermission class="System.Security.Permissions.FileDialogPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
version="1"
Access="Open"/>
<IPermission class="System.Security.Permissions.IsolatedStorageFilePermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
version="1"
Allowed="ApplicationIsolationByUser"
UserQuota="1024000"/>
<IPermission class="System.Security.Permissions.SecurityPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
version="1"
Flags="Execution"/>
<IPermission class="System.Security.Permissions.UIPermission, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
version="1"
Window="SafeTopLevelWindows"
Clipboard="OwnClipboard"/>
<IPermission class="System.Drawing.Printing.PrintingPermission, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"
version="1"
Level="SafePrinting"/>
<IPermission class="System.Security.Permissions.MediaPermission, WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
version="1"
Audio="SafeAudio"
Video="SafeVideo"
Image="SafeImage"/>
<IPermission class="System.Security.Permissions.WebBrowserPermission, WindowsBase, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"
version="1"
Level="Safe"/>
</PermissionSet>
FailedAssemblyInfo: NULL
Method: Void InitWithRestrictedPermissions(System.Configuration.RuntimeConfigurationRecord, System.Configuration.FactoryRecord)
Zone: NoZone
Url:
Message: Request failed.
Data: System.Collections.ListDictionaryInternal
TargetSite: System.Object CreateInstance(System.RuntimeType, Boolean, Boolean, Boolean ByRef, System.RuntimeMethodHandleInternal ByRef, Boolean ByRef)
HelpLink: NULL
Source: mscorlib
StackTrace Information
*********************************************
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)
有问题的配置文件部分(带行号):
4 <configSections>
5 <section name="exceptionManagement"
6 type="Company.Shared.ExceptionManagement.ExceptionManagerSectionHandler, Company.Shared" />
7 </configSections>
8 <exceptionManagement>
9 <publisher assembly="Company.Shared" type="Company.Shared.ExceptionManagement.DefaultPublisher"
10 logName="CPODSOracleDataExchange" applicationName="CPODSOracleDataExchange Service" />
11 <publisher assembly="Company.Shared" type="Company.Shared.ExceptionManagement.ExceptionManagerSMTPPublisher"
12 from="CPODSOracleDataExchangeService@Company.com"
13 defaultRecipients="dev1@Company.com,dev2@Company.com"
14 applicationName="CPODSOracleDataExchange Service" />
15 </exceptionManagement>
这个完全相同的配置在我们的开发环境中运行良好。据我所知,这些是相同的环境,并且两种服务都在相同的代码库下运行。
关于什么是权限失败有什么想法吗?我们正在努力做的一件事是创建自定义日志,但即使我们删除了试图写入不存在的自定义日志的默认发布者,该过程仍然失败。
最佳答案
事实证明这是一个难以理解的安装问题。
我们用旧的 exe 卸载了服务,并使用 64 位 4.0 框架重新安装,问题消失了。
关于c# - "An error occurred creating the configuration section handler for"-,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16364173/
我是一名优秀的程序员,十分优秀!