none
Error while talking WCF using net.tcp RRS feed

  • Question

  • I am getting following error  in Trace viewer while communicating WCF service from WPF application using NetTCP

    The ' ' character, hexadecimal value 0x20, cannot be included in a name.
    Parameter name: name

    I am getting error on following even of WPF
    ===============================
    void onStartClick(object sender, EventArgs e)  {               
            productsServiceHost = new ServiceHost(typeof(ProductsServiceImpl));
            ...
    }


    Here is my app.config of WPF
    ====================
    <?xml version="1.0"?>
    <configuration>
        <configSections>
            <section name="dataConfiguration" type="Microsoft.Practices.EnterpriseLibrary.Data.Configuration.DatabaseSettings, Microsoft.Practices.EnterpriseLibrary.Data, Version=5.0.414.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="true" />
        </configSections>
        <dataConfiguration defaultDatabase="AdventureWorksConnection" />
        <connectionStrings>
            <add name="AdventureWorksConnection" connectionString="Data Source=WIN764PRSP1\SQL2008;Initial Catalog=AdventureWorks2008;User ID=sa;Password=!@Sql2008@!"
                providerName="System.Data.SqlClient" />
        </connectionStrings>
        <startup>
            <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.0"/>
        </startup>


        <system.serviceModel>
            <services>
                <service behaviorConfiguration="ProductsTcpBehavior" name="ProductsService.ProductsServiceImpl">
                    <endpoint address="net.tcp://localhost:8080/TcpProductsService"
                    binding="netTcpBinding" bindingConfiguration="" name="NetTcpBinding_IProductsService "
                    contract="ProductsService.IProductsService" />
                </service>
            </services>
            <behaviors>
                <serviceBehaviors>
                    <behavior name="ProductsTcpBehavior">                    
                        <serviceDebug includeExceptionDetailInFaults="True" />
                        <serviceMetadata />
                    </behavior>
                </serviceBehaviors>
            </behaviors>
        </system.serviceModel>
    </configuration>

    Here is my app.config of Console Client Application
    ===================================
    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
        <system.serviceModel>
            <bindings>
                <basicHttpBinding>
                    <binding name="NetTcpBinding_IProductsService" closeTimeout="00:01:00"
                        openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
                        allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                        maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
                        messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
                        useDefaultWebProxy="true">
                        <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                            maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                        <security mode="None">
                            <transport clientCredentialType="None" proxyCredentialType="None"
                                realm="" />
                            <message clientCredentialType="UserName" algorithmSuite="Default" />
                        </security>
                    </binding>
                </basicHttpBinding>
            </bindings>
            <client>
                <endpoint address="net.tcp://localhost:8080/TcpProductsService"
                    binding="netTcpBinding" bindingConfiguration="" contract="ProductsService.IProductsService"
                    name="NetTcpBinding_IProductsService" />
            </client>
        </system.serviceModel>
    </configuration>

    Here is Program.Cs file in Client
    ======================
     static void Main(string[] args)
            {
                Console.WriteLine("Press ENTER when the service has started");
                Console.ReadLine();

                // Create a proxy object and connect to the service
                //ProductsServiceClient proxy =
                //    new ProductsServiceClient("BasicHttpBinding_IProductsService");

                ProductsServiceClient proxy = new
                    ProductsServiceClient("NetTcpBinding_IProductsService");

                // Test the operations in the service

                // Obtain a list of all products
                Console.WriteLine("Test 1: List all products");
                string[] productNumbers = proxy.ListProducts();
                foreach (string productNumber in productNumbers)
                {
                    Console.WriteLine("Number: " + productNumber);
                }
                Console.WriteLine();

               ....
    }

    Can anyone assist where i am wrong.


    Sunday, March 15, 2015 3:16 AM

Answers

All replies

  • Hi IT Quest,

    Based on your config file, I can see that you are using the following service name:
    name="ProductsService.ProductsServiceImpl"
    So please try to modify the service name in here:

    void onStartClick(object sender, EventArgs e)  {                
             productsServiceHost = new ServiceHost(typeof(ProductsServiceImpl));
             ...
     }

    As following:
    void onStartClick(object sender, EventArgs e)  {                
             productsServiceHost = new ServiceHost(typeof(ProductsService.ProductsServiceImpl));
             ...
     }

    Best Regards,
    Amy Peng


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, March 16, 2015 6:07 AM
    Moderator
  • I tried as suggested by you. but still showing same error
    Friday, March 20, 2015 12:04 AM
  • Hi IT Quest,

    In your scenario, I see that you have hosted your WCF Service on the WPF application and it throws exception from WPF application, so in my mind, the WPF does not work well when hosting the WCF Service, please try to do a test by using the WcfTestClient(https://msdn.microsoft.com/en-us/library/bb552364(v=vs.110).aspx) to see if your WCF Service works well.
    The following article show us how to host a WCF service using WPF, please try to check it:
    https://soumya.wordpress.com/2010/05/26/wcf-simplified-part-7-hosting-a-wcf-service-using-wpf/ .

    Please also try to enable the WCF tracing to help find the root cause.
    #How to enable WCF tracing:
    https://msdn.microsoft.com/en-us/library/ms733025(v=vs.110).aspx .

    Besides, if the problem still exist, it will better if you can try to post a simple reproduce project in here.

    Best Regards,
    Amy Peng


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.



    Monday, March 23, 2015 5:49 AM
    Moderator