WCF托管在Windows服务中获取安全例外,即使它应该在完全信任中运行

时间:2011-07-12 15:26:32

标签: .net wcf

我们在Windows服务中托管WCF服务(.NET 4.0)。它在大多数机器上运行良好,但在某些机器上会引发以下异常:“错误:为system.serviceModel / bindings创建配置节处理程序时发生错误:该程序集不允许部分信任的调用者。” (完整的堆栈跟踪位于此帖的底部)

在部分受信任的环境中,似乎有点期待这个例外,但对于我们所知道的所有人,我们知道(或者应该)在完全信任下运行:

  • 所有内容都安装在本地C:\ drive
  • Windows服务正在管理员帐户下运行
  • 未设置任何软件限制政策
  • 我们没有做任何明确在中等信任下运行的事情

事实证明,当我们从app.config中删除绑定部分(并在代码中进行配置)时,一切正常。它只是读取导致问题的配置部分。

问题:

  • 那么可能导致此安全异常的原因是什么?
  • 我们如何判断我们是否真的在完全信任下奔跑?
  • 我们需要更改哪些计算机设置或配置选项以避免此安全例外?

感谢任何帮助

这是堆栈跟踪:

Connect.Host.Connect.InitializeServiceHost(:0) Connect.Host.Connect.InitializeServiceHost(:0) [(null)] - Error: An error occurred creating the configuration section handler for system.serviceModel/bindings: That assembly does not allow partially trusted callers. (C:\Connect\MyApp\Host\Connect.Host.exe.Config line 54), stacktrace:    at System.Configuration.BaseConfigurationRecord.EvaluateOne(String[] keys, SectionInput input, Boolean isTrusted, FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult)
   at System.Configuration.BaseConfigurationRecord.Evaluate(FactoryRecord factoryRecord, SectionRecord sectionRecord, Object parentResult, Boolean getLkg, Boolean getRuntimeObject, Object& result, Object& resultRuntimeObject)
   at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
   at System.Configuration.BaseConfigurationRecord.GetSectionRecursive(String configKey, Boolean getLkg, Boolean checkPermission, Boolean getRuntimeObject, Boolean requestIsHere, Object& result, Object& resultRuntimeObject)
   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 System.Configuration.ClientConfigurationSystem.System.Configuration.Internal.IInternalConfigSystem.GetSection(String sectionName)
   at System.Configuration.ConfigurationManager.GetSection(String sectionName)
   at System.ServiceModel.Activation.AspNetEnvironment.UnsafeGetSectionFromConfigurationManager(String sectionPath)
   at System.ServiceModel.Activation.AspNetEnvironment.UnsafeGetConfigurationSection(String sectionPath)
   at System.ServiceModel.Configuration.ConfigurationHelpers.UnsafeGetAssociatedSection(ContextInformation evalContext, String sectionPath)
   at System.ServiceModel.Description.ConfigLoader.LookupChannel(ContextInformation configurationContext, String configurationName, ContractDescription contract, EndpointAddress address, Boolean wildcard, Boolean useChannelElementKind, ServiceEndpoint& serviceEndpoint)
   at System.ServiceModel.ChannelFactory.InitializeEndpoint(String configurationName, EndpointAddress address)
   at System.ServiceModel.ChannelFactory`1..ctor(String endpointConfigurationName, EndpointAddress remoteAddress)
   at System.ServiceModel.EndpointTrait`1.CreateSimplexFactory()
   at System.ServiceModel.ClientBase`1.CreateChannelFactoryRef(EndpointTrait`1 endpointTrait)
   at System.ServiceModel.ClientBase`1.InitializeChannelFactoryRef()
   at System.ServiceModel.ClientBase`1..ctor()
   at Connect.BL.EndpointManager.RegisterEndpoint(Int32 endpointId)
   at Connect.Host.Connect.InitializeServiceHost() for endpoint 0

0 个答案:

没有答案