Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6152503
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T19:55:53+00:00 2026-05-23T19:55:53+00:00

In a WCF application we have a servicecontract with attributes: namespace We.Work { [ServiceContract(Namespace

  • 0

In a WCF application we have a servicecontract with attributes:

namespace We.Work {
    [ServiceContract(Namespace = "We", Name = "IWork", SessionMode = SessionMode.NotAllowed)]
        public interface IWork

an implementation of the servicecontract with attributes:

namespace We.Work {
    [ServiceBehavior(Name = "Work", Namespace = "We",
           IncludeExceptionDetailInFaults = true,
           InstanceContextMode = InstanceContextMode.PerCall,
           ConcurrencyMode = ConcurrencyMode.Multiple,
           ReleaseServiceInstanceOnTransactionComplete = false
        )]
        public class WorkImplementation : IWork

a servicehost (windows service or console application for development)

namespace We.Host {
// ....
        workServiceHost = new ServiceHost(typeof(We.Work.WorkImplementation));
        workServiceHost.Faulted += new EventHandler(Host_Faulted);
        workServiceHost.Open();

and last but not least an app.config:

<service behaviorConfiguration="WorkServiceBehaviour" name="We.Work.WorkImplementation">
        <endpoint behaviorConfiguration="WorkEndPointBehaviour" binding="wsHttpBinding" bindingConfiguration="WorkWsHttpBindingConfig" name="WorkEndPoint" contract="We.Work.IWork"/>
        <host> <baseAddresses> <add baseAddress="http://.../Work.svc"/>            </baseAddresses> </host>
      </service>

<behaviors>
      <endpointBehaviors>
        <behavior name="WorkEndPointBehaviour">
          <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
        </behavior>
      </endpointBehaviors>
      <serviceBehaviors>
        <behavior name="WorkServiceBehaviour">
          <serviceDebug httpHelpPageEnabled="true" httpsHelpPageEnabled="true" includeExceptionDetailInFaults="true"/>
          <dataContractSerializer maxItemsInObjectGraph="2147483647"/>
          <serviceMetadata/>
          <serviceThrottling maxConcurrentCalls="25" maxConcurrentSessions="25" maxConcurrentInstances="25"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>

Questions:
Is it possible to mix app.config and attributes, which configuration has precendence, what is a good practice?

E.g. does ServiceContract(SessionMode = SessionMode.NotAllowed) prevent wsHttpBinding from using sessions?

[Answered: how can I be sure the settings in app.config are really applied — the fully qualified name works.]

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-23T19:55:53+00:00Added an answer on May 23, 2026 at 7:55 pm

    The service name attribute in the config file must be the fully-qualified name of the service class for WCF to pick up the configuration automatically.

    It is possible to mix config and code. However, there is no precedence as such. WCF will read the config file when you instantiate the ServiceHost. If you want to set additional properties in code, they will overwrite what’s already there.

    Best practice is entirely up to you. The purpose of the config file elements is to decouple the service configuration and implementation, which may or may not be a consideration in your deployment.

    UPDATE

    Attributes on the service class code are a different story. The purpose of some attributes are to let the developer say “I demand config that is consistent with this attribute, or my service won’t run as designed”. Therefore, although attributes won’t actually override config, WCF will check that config is consistent with attributes and refuse to start the service if they are not consistent.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a wcf application hosted in a windows service running a local windows
We currently have developed an application using WCF. Our clients make connections to different
I have client application that uses WCF service to insert some data to backend
I have a Console application hosting a WCF service. I would like to be
I have a Silverlight 2 application that is consuming a WCF service. As such,
I have a WCF service that is hosted in a windows application. The service
I have a silverlight 2 beta 2 application that accesses a WCF web service.
I have a Silverlight application that communications with an ASP.NET backend through WCF. I
I have a Silverlight application in which I would like to call a WCF
I have a WCF service that runs in my web application that provides data

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.