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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T17:31:41+00:00 2026-05-13T17:31:41+00:00

I am trying to create a simple ConsoleApplication in which i would like to

  • 0

I am trying to create a simple ConsoleApplication in which i would like to host a simple wcf service.

Here is the code for my

namespace HostConsoleApplication
{
    class Program
    {
        static void Main(string[] args)
        {
            using (System.ServiceModel.ServiceHost host = new System.ServiceModel.ServiceHost(typeof(FirstWcfService.Service)))
            {
                host.Open();
                Console.WriteLine("Sai");
                Console.ReadLine();
            }
        }
    }
}

Then i have added an app.config which looks like this:

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
    <system.serviceModel>
        <services>
            <service name="FirstWcfService.Service" behaviorConfiguration="ServiceBehavior">
                <endpoint address="FirstWcfService" binding="netTcpBinding" contract="FirstWcfService.IService"/>
                <endpoint contract="IMetadataExchange" binding="mexHttpBinding" address="mex" />
                <host>
                    <baseAddresses>
                        <add baseAddress="net.tcp://localhost:9101/"/>
                    </baseAddresses>
                </host>
            </service>
        </services>
        <behaviors>
            <serviceBehaviors>
                <behavior name="ServiceBehavior" >
                    <serviceMetadata httpGetEnabled="false" />
                </behavior>
            </serviceBehaviors>
        </behaviors>
    </system.serviceModel>
</configuration>

When i run the host console app i get this exception:

System.InvalidOperationException was
unhandled Message=”Could not find a
base address that matches scheme http
for the endpoint with binding
MetadataExchangeHttpBinding.
Registered base address schemes are
[net.tcp].”
Source=”System.ServiceModel”
StackTrace:
at System.ServiceModel.ServiceHostBase.MakeAbsoluteUri(Uri
relativeOrAbsoluteUri, Binding
binding, UriSchemeKeyedCollection
baseAddresses)
at System.ServiceModel.Description.ConfigLoader.LoadServiceDescription(ServiceHostBase
host, ServiceDescription description,
ServiceElement serviceElement,
Action`1 addBaseAddress)
at System.ServiceModel.ServiceHostBase.LoadConfigurationSectionInternal(ConfigLoader
configLoader, ServiceDescription
description, ServiceElement
serviceSection)
at System.ServiceModel.ServiceHostBase.LoadConfigurationSectionInternal(ConfigLoader
configLoader, ServiceDescription
description, String configurationName)
at System.ServiceModel.ServiceHostBase.ApplyConfiguration()
at System.ServiceModel.ServiceHostBase.InitializeDescription(UriSchemeKeyedCollection
baseAddresses)
at System.ServiceModel.ServiceHost.InitializeDescription(Type
serviceType, UriSchemeKeyedCollection
baseAddresses)
at System.ServiceModel.ServiceHost..ctor(Type
serviceType, Uri[] baseAddresses)
at HostConsoleApplication.Program.Main(String[]
args) in C:\Documents and
Settings\navin.pathuru\My
Documents\Visual Studio
2008\Projects\Solution2\HostConsoleApplication\Program.cs:line
13
at System.AppDomain._nExecuteAssembly(Assembly
assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String
assemblyFile, Evidence
assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object
state)
at System.Threading.ExecutionContext.Run(ExecutionContext
executionContext, ContextCallback
callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:

Just wondering if how to fix this.
Thanks
N

  • 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-13T17:31:41+00:00Added an answer on May 13, 2026 at 5:31 pm

    Well, I think the problem is this:

    • you have a base address for net.tcp
    • you have a MEX http endpoint defined (but no http base address)

    Basically if you want to use MEX over http, you need to supply either a full address for the MEX endpoint, or a http base address (if you only specify a relative address).

    Solution 1: specify a full address for the MEX endpoint:

     <services>
        <service name="FirstWcfService.Service" 
                  behaviorConfiguration="ServiceBehavior">
           <endpoint 
               address="FirstWcfService" 
               binding="netTcpBinding" 
               contract="FirstWcfService.IService"/>
           <endpoint 
               address="http://localhost:9102/FirstWcfService/mex"
               binding="mexHttpBinding" 
               contract="IMetadataExchange"  />
            ......
        </service>
    </services>
    

    Solution 2: define an HTTP base address, too:

     <services>
        <service name="FirstWcfService.Service" 
                  behaviorConfiguration="ServiceBehavior">
           <endpoint 
               address="FirstWcfService" 
               binding="netTcpBinding" 
               contract="FirstWcfService.IService"/>
           <endpoint 
               address="mex"
               binding="mexHttpBinding" 
               contract="IMetadataExchange"  />
           <host>
               <baseAddresses>
                   <add baseAddress="net.tcp://localhost:9101/"/>
                   <add baseAddress="http://localhost:9102/"/>
               </baseAddresses>
           </host>
        </service>
    </services>
    

    Solution 3: use the mexTcpBinding instead

     <services>
        <service name="FirstWcfService.Service" 
                  behaviorConfiguration="ServiceBehavior">
           <endpoint 
               address="FirstWcfService" 
               binding="netTcpBinding" 
               contract="FirstWcfService.IService"/>
           <endpoint 
               address="mex"
               binding="mexTcpBinding" 
               contract="IMetadataExchange"  />
            ......
        </service>
    </services>
    

    Any of those three options should should solve it.

    A word of caution: I find it quite risky to call your service behavior configuration “ServiceBehavior”……

    <serviceBehaviors>
        <behavior name="ServiceBehavior" >
    

    My recommendation: call your first and default configuation just plain “Default” (or “DefaultBehavior”)

    <serviceBehaviors>
        <behavior name="Default" >
    

    and only start giving out other names if you have multiple configurations.

    Calling this ServiceBehavior just seems to be asking for trouble some time later on…..

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

Sidebar

Related Questions

I'm trying to create a simple BaSH-like grammar on ANTLRv3 but haven't been able
I'm trying to send a POST request to a simple WCF service I wrote,
I'm trying to create a simple stored procedure which I can use to write
I am trying to create a simple dialog in MFC using Visual C++. My
I am trying to create a simple page that enters data in to a
I'm trying to create a simple toggling sidebar using jquery, where it expands and
I'm playing with the ASP.NET MVC Framework, trying to create a simple site. My
I am trying to create a rather simple effect on a set of images.
I'm new to postgreSQL and I have a simple question: I'm trying to create
Im using Eclipse 3.4, EclipseMe 1.7.9. Im trying to deploy/create package a simple project

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.