我有一个 .NET 4 .exe(Winform 桌面应用程序),已向其中添加了 WCF 行为扩展。该应用程序可以在本地计算机上正常加载,但在通过网络加载时会引发 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 的内部异常