簡體   English   中英

找不到與綁定MetadataExchangeTcpBinding自托管端點的終結點計算機匹配方案net.tcp的基地址

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

我創建了一個具有Datacontract和服務合約及其實現的類庫。 然后,我創建了一個控制台應用程序來托管wcf服務。 我在下面的app.config文件中定義了WCF設置。 <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>

然后我編制了program.cs文件。

       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;
        } 

我已經從Windows功能的開和關激活了WCF for Non HTTP。

我想在控制台應用程序中托管此wcf服務,有些文章建議我需要在IIS中設置nettcp綁定。 我為什么要這么做?

IIS是WCF服務的替代宿主,即您可以將其宿主在控制台應用程序中或IIS中。 據我了解,如果使用控制台應用程序,則無需設置IIS。

嘗試將配置中的“ net:tcp”更改為“ net.tcp”。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM