简体   繁体   中英

Could not find a base address that matches scheme net.tcp for the endpoint with binding MetadataExchangeTcpBinding self hosting

I have created a class library which have Datacontract and service contract and its implementation. Then I created a console application to host the wcf service. Where i have defined WCF setting in app.config file which is below. <configuration> <system.serviceModel> <services> <service name="TestService.TestService" behaviorConfiguration="tcpbindingConfiguration"> <host> <baseAddresses> <add baseAddress="net:tcp://FullComputerName:9002/TestService"/> </baseAddresses> </host> <endpoint address="net:tcp://FullComputerName:9002/TestService" binding="netTcpBinding" contract="TestService.ITestServiceContract"></endpoint> <endpoint address="mex" binding="mexTcpBinding" contract="IMetadataExchange"></endpoint> </service> </services> <behaviors> <serviceBehaviors> <behavior name="tcpbindingConfiguration"> <serviceMetadata httpGetEnabled="true"/> </behavior> </serviceBehaviors> </behaviors> </system.serviceModel> <startup> <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" /> </startup> </configuration>

Then I program.cs File.

       ServiceHost sh = null;

        try
        {
            sh = new ServiceHost(typeof(TestService.TestService));
            sh.Open();

            Console.WriteLine("Service started at net:tcp//FullComputerName:9002/TestService");
        }
        catch (Exception ex)
        {
            sh = null;
            Console.WriteLine("Service  cann't started");
            throw;
        } 

I have activate the WCF for Non HTTP from windows features on and off.

I want to host this wcf service in console application, Some article suggest that i need to set nettcp binding in IIS. Why i do that?

IIS is an alternative hosting for your WCF service, that is you either host it in your console application or in IIS. As far as I understand, there should be no need to setup IIS, if you use a console application.

Try changing "net:tcp" in your configuration to "net.tcp".

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM