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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T00:49:34+00:00 2026-05-19T00:49:34+00:00

i use a WCF-Service. It workes fine, and if i use a forbidden IP

  • 0

i use a WCF-Service.

It workes fine, and if i use a forbidden IP it shows me a message.
But if i change the ip in my textbox to the right IP it will be again catch the TCP exception, with the OLD IP… The IP-string in the textbox is the corret one and all variables contains the right IP…

The exception:

CommunicationException TCP-Fehler
(10049: Die angeforderte Adresse ist
in diesem Kontext ungültig) beim
Lauschen am
IP-Endpunkt=192.168.178.2:7997.

Should be 192.168.178.25
And after correcting the IP in the textbox and restarting the server i get the same exception with the old IP…

Here is my method:
I create all ressources new in this methode.
Only the ServiceHost host; Variable is stored outside the methode and i tried to set it null before starting or after exception.

Configure Host:

private void MenuItemServerStart_Click(object sender, RoutedEventArgs e)
        {
            **[ omitted ]**

            //Define base addresses so all 
            //endPoints can go under it

            Uri tcpAdrs = new Uri("net.tcp://" +
                textBoxLocalIP.Text.ToString() + ":" +
                textBoxPort.Text.ToString() + "/WPFHost/");

            Uri httpAdrs = new Uri("http://" +
                textBoxLocalIP.Text.ToString() + ":" +
                (int.Parse(textBoxPort.Text.ToString()) + 1).ToString() +
                "/WPFHost/");

            Uri[] baseAdresses = { tcpAdrs, httpAdrs };

            try
            {
                host = new ServiceHost(typeof(ChatService.ChatService), baseAdresses);
            }
            catch (TargetInvocationException ex)
            {
                if (ex.InnerException != null)
                {
                    **[ omitted ]**
                }

                return;
            }
            catch (Exception)
            {
                **[ omitted ]**
            }

            NetTcpBinding tcpBinding = new NetTcpBinding(SecurityMode.None, true);
            //Updated: to enable file transefer of 64 MB
            tcpBinding.MaxBufferPoolSize = (int)67108864;
            tcpBinding.MaxBufferSize = 67108864;
            tcpBinding.MaxReceivedMessageSize = (int)67108864;
            tcpBinding.TransferMode = TransferMode.Buffered;
            tcpBinding.ReaderQuotas.MaxArrayLength = 67108864;
            tcpBinding.ReaderQuotas.MaxBytesPerRead = 67108864;
            tcpBinding.ReaderQuotas.MaxStringContentLength = 67108864;
            tcpBinding.MaxConnections = 100;

            **[ omitted ]**

            host.AddServiceEndpoint(typeof(ChatService.IChatService),
                                    tcpBinding, "tcp");

            //Define Metadata endPoint, So we can 
            //publish information about the service
            ServiceMetadataBehavior mBehave =
                           new ServiceMetadataBehavior();
            host.Description.Behaviors.Add(mBehave);

            host.AddServiceEndpoint(typeof(IMetadataExchange),
                MetadataExchangeBindings.CreateMexTcpBinding(),
                "net.tcp://" + textBoxLocalIP.Text.ToString() + ":" +
                (int.Parse(textBoxPort.Text.ToString()) - 1).ToString() +
                "/WPFHost/mex");

Start host (Exception):

            try
            {
                **host.Open();** **//Exception here !!!**
            }
            catch (Exception ex)
            {
                **[ omitted ]**
            }
            finally
            {
                if (host.State == CommunicationState.Opened)
                {
                    ((StatusBarItem)statusBar1.Items.GetItemAt(0)).Content = "Gestartet";
                    MenuItemServerStop.IsEnabled = true;
                }
            }

        }
  • 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-19T00:49:34+00:00Added an answer on May 19, 2026 at 12:49 am

    I have a hunch that there may be some static state associated with the channel runtime infrastructure for HTTP bindings, which maintains details of HTTP listeners keyed by service Uri. If you are not properly tearing down ServiceHost instances which threw on Open, perhaps the old details remain registered in this static state.

    What happens in your catch block following the call to host.Open()? If you are not calling host.Abort() and host.Dispose() on the instances which threw on Open, this might be the problem.

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

Sidebar

Related Questions

I'd like to query WMI for WCF service information, but I'd rather not use
I have been making use of the WCF Authentication Service in ASP.Net but I
I have a simple wcf Service Contract that works fine if I use the
I have a WCF service that works perfectly fine unless I attempt to use
I have a WCF service and use Spring.ServiceModel.Activation.ServiceHostFactory as a factory in my *.svc.
I have a WCF service where in I use Log4Net for logging information to
I just started to use WCF Rest project template to design a REST service,
I have a WCF service, that use tcp for the communication. When I try
I have a WCF service that processes some messages. I use EntityFramework to retrieve
So, I've seperated my WCF service contracts into discrete contracts for re-use. I use

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.