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 7688701
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T19:59:07+00:00 2026-05-31T19:59:07+00:00

Trying to run a self-hosted app on my Win 7 system, with little success.

  • 0

Trying to run a self-hosted app on my Win 7 system, with little success. The app starts up but I can’t access it from WCF Test Client or by adding a reference in VS. I’ve read what seems like 1000 posts about similar problems, but none of the solutions seem to fit.

I did this:

netsh http add urlacl url=http://+:9090/hello user=LocalPC\UserName

And then this:

netsh http add iplisten ipaddress=0.0.0.0:9090

Here’s the code to do the

void MainWindow_Loaded(object sender, RoutedEventArgs e)
{
        Uri baseAddress = new Uri("http://localhost:9090/hello");

        // Create the ServiceHost.
        using (ServiceHost host = new ServiceHost(typeof(HelloWorldService), baseAddress))
        {
            // Enable metadata publishing.
            ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
            smb.HttpGetEnabled = true;
            smb.MetadataExporter.PolicyVersion = PolicyVersion.Policy15;
            host.Description.Behaviors.Add(smb);

            // Add MEX endpoint
            host.AddServiceEndpoint(
              ServiceMetadataBehavior.MexContractName,
              MetadataExchangeBindings.CreateMexHttpBinding(),
              "mex");

            // Add application endpoint
            host.AddServiceEndpoint(typeof(IHelloWorldService), new WSHttpBinding(), "");                

            // Open the ServiceHost to start listening for messages. Since
            // no endpoints are explicitly configured, the runtime will create
            // one endpoint per base address for each service contract implemented
            // by the service.
            try
            {
                host.Open();
            }
            catch (Exception excep)
            {
                string s = excep.Message;
            }
        }
    }

When I try to access from WCF Test Client I get:

Error: Cannot obtain Metadata from http://localhost:9090/hello If this is a Windows (R) Communication Foundation service to which you
have access, please check that you have enabled metadata publishing at
the specified address. For help enabling metadata publishing, please
refer to the MSDN documentation at
http://go.microsoft.com/fwlink/?LinkId=65455.
WS-Metadata Exchange Error URI: http://localhost:9090/hello
Metadata contains a reference that cannot be resolved: ‘http://localhost:9090/hello’.
There was no endpoint listening at http://localhost:9090/hello that
could accept the message. This is often caused by an incorrect address
or SOAP action. See InnerException, if present, for more details.
Unable to connect to the remote server No connection could be made
because the target machine actively refused it 127.0.0.1:9090
HTTP GET Error URI: http://localhost:9090/hello There was an error
downloading ‘http://localhost:9090/hello’. Unable to connect to the
remote server No connection could be made because the target
machine actively refused it 127.0.0.1:9090

When I try to add a service reference I get:

There was an error downloading ‘http://localhost:9090/hello’.
Unable to connect to the remote server
No connection could be made because the target machine actively refused it
127.0.0.1:9090
Metadata contains a reference that cannot be resolved: ‘http://localhost:9090/hello’.
There was no endpoint listening at http://localhost:9090/hello that could accept the
message. This is often caused by an incorrect address or SOAP action. See
InnerException, if present, for more details.
Unable to connect to the remote server
No connection could be made because the target machine actively refused it 127.0.0.1:9090
If the service is defined in the current solution, try building the solution and adding the service reference again.

  • 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-31T19:59:08+00:00Added an answer on May 31, 2026 at 7:59 pm

    The problem is that you are letting the ServiceHost go out of scope immediately.

    The using statement is there as a convenience to do cleanup when that block of code goes out of scope, but you have nothing in place to prevent that. So in essence you are opening the connection, but then it is being disposed almost instantly… which closes the connection.

    So long as you don’t run into any permissions issues, this approach should work for you. That being said, this is just demo-ware. In reality you probably don’t want your WCF service tied directly to your form, but rather defined at the application level.

    public partial class WcfHost : Form
    {
        private ServiceHost _svcHost;
        private Uri _svcAddress = new Uri("http://localhost:9001/hello");
    
        public WcfHost()
        {
            _svcHost = new ServiceHost(typeof(HelloWorldService), _svcAddress);
    
            ServiceMetadataBehavior smb = new ServiceMetadataBehavior();
            smb.HttpGetEnabled = true;
            smb.MetadataExporter.PolicyVersion = PolicyVersion.Policy15;
            _svcHost.Description.Behaviors.Add(smb);
    
            InitializeComponent();
    
            FormClosing += WcfHost_FormClosing;
        }
    
        private void WcfHost_Load(object sender, EventArgs e)
        {
            try
            {
                _svcHost.Open(TimeSpan.FromSeconds(10));
                lblStatus.Text = _svcHost.State.ToString();
            }
            catch(Exception ex)
            {
                lblStatus.Text = ex.Message;
            }            
        }
    
        void WcfHost_FormClosing(object sender, FormClosingEventArgs e)
        {
            _svcHost.Close();
    
            lblStatus.Text = _svcHost.State.ToString();
        }
    }
    
    [ServiceContract]
    public interface IHelloWorldService
    {
        [OperationContract]
        string SayHello(string name);
    }
    
    public class HelloWorldService : IHelloWorldService
    {
        public string SayHello(string name)
        {
            return string.Format("Hello, {0}", name);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to write an app using GtkClutter but I can't get the actors
I am trying to build a self-hosted PHP site, but I am having trouble
@with_checker([int]) def check_sort(list_of_ints): self.assertTrue(isinstance(list_of_ints, list)) self.assertTrue(len(list) == len(qsort(list))) self.assertTrue(False) I'm trying to run this,
I am trying run a program from a qmake .pro file which modifies the
Trying to run Jison unit tests, but the command fails. How do I fix
I am trying to run django on my ubuntu lucid, but I get the
I'm trying to run this test: self.assertRaises(AttributeError, branch[0].childrennodes) , and branch[0 ] does not
I'm trying to send some data from the server to the client, but the
I am trying to run a very simple server/client ssl code with a self
I am trying to run a shell from my python program. I have used

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.