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

  • Home
  • SEARCH
  • 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 860595
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T08:50:25+00:00 2026-05-15T08:50:25+00:00

I have a WCF that is in use now for over a year, coded

  • 0

I have a WCF that is in use now for over a year, coded by someone else and i’m trying to refactor it but the way the folder structure is organized and the svc.cs file containing the methods is not what I am used to from WCF samples I completed.

Here is what I’m trying to achieve. Since none of the settings changed over the last year I am asked to hardcode all the service’s settings in code. The service is hosted within big and existing web application(and I have to leave it in there), the svc file contains the method getting called by the client, and this svc.cs file is not located at the root of the virtual directory but deeper, lets say <virtualDirectory>/WebServices/PotatoWebService/PotatoWebService.svc, does having it not in the virtual directory root cause any problem?

Since I am moving the configuration out of the config file, I am now creating the service, host, endpoint, binding within the web application’s global.axax.cs file, at ApplicationStart(), is that the right place to start this service within a web application?

Is it possible to move everything in code, not just the endPoint but also the entire content of the behavior, service and system.ServiceModel found in the web.config file, in order to ‘clean’ the config file, and stop scaring support and config managers with settings they don’t need?

If it is, I have been trying for 2 days to get this to work without success. What I have now according to netstat is a service up and running but when I open my svc file in the browser an exception pops saying the service dosent have any endpoints defined, although according to nstat I have a service running:

netstat -a | find LISTENING

...
  TCP    machineName:8097      elamontagne.potato.com:0  LISTENING
...

So I have a service running but a svc file that is not aware of it and can’t use it’s endpoints, a client trying to contact the service and can’t find it because service has no endpoint, any tips to narrow down the problem, tips for trouble shooting this situation?

     //Address
    string hostingAddress = "PotatoVirtualDirectory/PotatoService/PotatoService.svc";   
    // Binding
    BasicHttpBinding PotatoServiceBinding = ConfigurePotatoServiceBinding(serviceSecurityMode);
    // Contract
    Type PotatoContract = typeof(IPotatoService);
    // Host
    this.PotatoServiceHost = new ServiceHost(typeof(PotatoService), new Uri("http://localhost:8097"));
    // Endpoint
    this.PotatoServiceHost.AddServiceEndpoint(PotatoContract, PotatoBinding, hostingAddress);
    // Behavior
    ConfigurePotatoServiceBehavior(this.PotatoServiceHost, PotatoServiceBinding);
    // Name
    this.PotatoServiceHost.Description.Name = "PotatoNamespace.PotatoService";
    //Start!
    this.PotatoServiceHost.Open();

This compiles and run, it gives me an running service in opened state. The client can’t find it at it’s usual location, and the svc file complains it has nohting in the web.config and wants an endpoint ServiceHasZeroAppEndpoints: “Service has zero application (non-infrastructure) endpoints”

I’ve step through the code in debug and all looks fine, service is openend, what I am missing, any tips to narrow down this problem?

Edit: Deriving from the service host factory worked well, thanks!

  • 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-15T08:50:25+00:00Added an answer on May 15, 2026 at 8:50 am

    You could write a custom service host factory where you could programatically configure the service instead of using a configuration file. Then in your .svc markup file you configure this custom factory:

    <%@ServiceHost Factory="CustomFactory" Service="MyService" %>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have an existing WCF service that makes use of wsDualHttpBinding to enable callbacks
I have a WCF service that uses basicHttpbinding in development. Now in product we
I have a WCF service that I have to reference from a .net 2.0
I have some WCF methods that are used to transmit information from a server
I have a WCF Service that should not enter the faulted state. If there's
I have a WCF service that is hosted in a windows application. The service
I have a WCF Service that exposes a method GetCustomers(). The internals of the
I have a WCF service that I call from a windows service. The WCF
I have a WCF service that uses a System.ServiceModel.Syndication.SyndicationFeed to create an RSS feed.
I have a WCF service that is using a custom ServiceAuthorizationManager . The custom

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.