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

Mar*_*kGr 6 .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>
Run Code Online (Sandbox Code Playgroud)

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

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
Run Code Online (Sandbox Code Playgroud)

具有System.Security.SecurityException的内部异常

pba*_*bar 5

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

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

我们所做的所有纠正是单击此文件的"属性"对话框上的"解锁"按钮(在Windows资源管理器中).