简体   繁体   English

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

[英]SecurityException when loading an app with a WCF behaviorExtension in the app.config over the network

I have an .NET 4 .exe (Winform Desktop app) to which I have added a WCF behaviorExtension. 我有一个.NET 4 .exe(Winform桌面应用程序),我已经添加了一个WCF behaviorExtension。 The app loads fine on the local machine, but throws a SecurityException when loaded across the network. 应用程序在本地计算机上加载正常,但在通过网络加载时会抛出SecurityException。 If I omit the setMaxFaultSizeBehavior behaviorExtension then I can load the app over the network. 如果我省略了setMaxFaultSizeBehavior behaviorExtension,那么我可以通过网络加载应用程序。 I would appreciate any information that could help get this working. 我将不胜感激任何有助于实现这一目标的信息。 I have confirmed that the files are not blocked, and the assembly name is an exact match, including spaces. 我已确认文件未被阻止,并且程序集名称完全匹配,包括空格。

The relevant part of the app.config looks like this (I shortened the type name and assembly name, in the actual config file, I use the full namespace and assembly name): 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>

The exception I get when running over the network is : 通过网络运行时遇到的异常是:

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

With an Inner Exception of System.Security.SecurityException 具有System.Security.SecurityException的内部异常

We just encountered the same problem last week. 我们上周遇到了同样的问题。 I was able to trace it back to a deployment error.... when copying the assembly files from a network location, we had forgotten to "unlock" them. 我能够将其追溯到部署错误....当从网络位置复制程序集文件时,我们忘记了“解锁”它们。

ie the assembly containing the WCF extension element was marked as unsafe by Windows (because it had been copied from a network location). 即,包含WCF扩展元素的程序集被Windows标记为不安全(因为它已从网络位置复制)。

All we did to correct it was to click the Unlock button on the Properties dialog for this file (in Windows Explorer). 我们所做的所有纠正是单击此文件的“属性”对话框上的“解锁”按钮(在Windows资源管理器中)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM