Visual Studio.NET - WCF Exception with Wrong Service Name
Here is the information on how to fix the WCF Exception with wrong service name.
SecurityException: Request for the permission of type 'System.Configuration.ConfigurationPermission, System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' failed.
This security exception is caused when used with typing wrong service name.
Wcf_Test_Service.TestService2 is used in web.config file which does exist in the application. The correct service name is : Wcf_Test_Service.TestService
<service name="Wcf_Test_Service.TestService2" behaviorConfiguration="MyServiceTypeBehaviors">
Security Exception
Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.
Exception Details: System.Security.SecurityException: Request for the permission of type 'System.Configuration.ConfigurationPermission, System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' failed.
Source Error:
|
Stack Trace:
[SecurityException: Request for the permission of type 'System.Configuration.ConfigurationPermission, System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' failed.]
System.Security.CodeAccessSecurityEngine.Check(Object demand, StackCrawlMark& stackMark, Boolean isPermSet) +0
System.Security.CodeAccessSecurityEngine.Check(CodeAccessPermission cap, StackCrawlMark& stackMark) +31
System.Security.CodeAccessPermission.Demand() +46
System.ServiceModel.Description.ConfigLoader.CheckAccess(IConfigurationContextProviderInternal element) +12106893
System.ServiceModel.Description.ConfigLoader.LookupService(String serviceConfigurationName) +12228035
System.ServiceModel.ServiceHostBase.ApplyConfiguration() +97
System.ServiceModel.ServiceHostBase.InitializeDescription(UriSchemeKeyedCollection baseAddresses) +192
System.ServiceModel.ServiceHost.InitializeDescription(Type serviceType, UriSchemeKeyedCollection baseAddresses) +49
System.ServiceModel.ServiceHost..ctor(Type serviceType, Uri[] baseAddresses) +151
System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(Type serviceType, Uri[] baseAddresses) +30
System.ServiceModel.Activation.ServiceHostFactory.CreateServiceHost(String constructorString, Uri[] baseAddresses) +420
System.ServiceModel.HostingManager.CreateService(String normalizedVirtualPath) +1440
System.ServiceModel.HostingManager.ActivateService(String normalizedVirtualPath) +44
System.ServiceModel.HostingManager.EnsureServiceAvailable(String normalizedVirtualPath) +615 |
To fix this error, use the correct service name in the web.config file:
<services>
<service name="Wcf_Test_Service.TestService" behaviorConfiguration="MyServiceTypeBehaviors">
<endpoint address=""
binding="basicHttpBinding"
contract="Wcf_Test_Service.ITestService2" >
</endpoint>
<endpoint address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
</service>
</services>
|