SecurityException when loading an application using WCF behavior in app.config application over the network

I have a .NET 4.exe (Winform Desktop application) to which I have added an extension for WCF. The application loads normally on the local computer, but when loading over the network throws a SecurityException. If I omit setMaxFaultSizeBehavior behaviorExtension, then I can download the application over the network. I would appreciate any information that could help with this. I confirmed that the files are not locked, and the assembly name is an exact match, including spaces.

The corresponding part of app.config looks like this (I shortened the type name and assembly name, in the actual configuration file, I use the full namespace and assembly name):

<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 that I get when working on 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 internal exception System.Security.SecurityException

+6
source share
1 answer

We faced the same problem last week. I was able to trace it to a deployment error ... when copying assembly files from a network location, we forgot to "unlock" them.

i.e. the assembly containing the WCF extension element was marked as unsafe by Windows (because it was copied from a network location).

All we did to fix this was to click the "Unlock" button in the "Properties" dialog box for this file (in Windows Explorer).

+5
source

Source: https://habr.com/ru/post/900400/


All Articles