通过网络在app.config中加载具有WCF behaviorExtension的应用程序时出现SecurityException

时间:2011-10-31 02:29:29

标签: .net wcf securityexception wcf-behaviour

我有一个.NET 4 .exe(Winform桌面应用程序),我已经添加了一个WCF behaviorExtension。应用程序在本地计算机上加载正常,但在通过网络加载时会抛出SecurityException。如果我省略了setMaxFaultSizeBehavior behaviorExtension,那么我可以通过网络加载应用程序。我将不胜感激任何有助于实现这一目标的信息。我已确认文件未被阻止,并且程序集名称完全匹配,包括空格。

app.config的相关部分看起来像这样(我缩短了类型名称和程序集名称,在实际的配置文件中,我使用完整的命名空间和程序集名称):

<system.serviceModel>
    <bindings configSource="bindings.config" />
    <client configSource="clients.config" />
    <extensions>
      <behaviorExtensions>
        <add name="setMaxFaultSizeBehavior" type="SetMaxFaultSizeBehavior, BehaviorAssembly, Version=1.8.0.0, Culture=neutral, PublicKeyToken=41b332442f1101cc" />
      </behaviorExtensions>
    </extensions>
    <behaviors>
      <endpointBehaviors>
       <behavior name="LargeQuotaBehavior">
          <dataContractSerializer maxItemsInObjectGraph="2147483600" />
          <setMaxFaultSizeBehavior />
       </behavior>
      </endpointBehaviors>
    </behaviors>

通过网络运行时遇到的异常是:

An error occurred creating the configuration section handler for system.serviceModel/behaviors: Request failed. (\\server\Share\app.exe.Config line 22)
Exception Type: System.Configuration.ConfigurationErrorsException
Source: System.Configuration

内在例外     System.Security.SecurityException

1 个答案:

答案 0 :(得分:5)

我们上周遇到了同样的问题。 我能够将其追溯到部署错误....当从网络位置复制程序集文件时,我们忘记了“解锁”它们。

即。包含WCF扩展元素的程序集被Windows标记为不安全(因为它已从网络位置复制)。

我们所做的只是点击此文件的“属性”对话框上的“解锁”按钮(在Windows资源管理器中)。

相关问题