C# 如何创建WCF代理而不使用托管在windows应用程序中的svc文件
我有两个应用程序。一个是承载wcf服务的winform服务器端,另一个是winform客户端应用程序,我必须在其中添加服务引用。没有任何svc文件。因此,当我试图在winform wcf客户端创建服务代理时,只需输入如下url http://localhost:7998/WPFHost/ 或 网tcp://localhost:7997/WPFHost/用于通过服务引用添加服务,然后获取错误。 元数据包含无法解析的引用:'net。tcp://localhost:7997/WPFHost/“。 在这里,我粘贴了wcf所在的wcf服务器端的完整app.config文件数据。请指导我app.config中的错误,添加服务引用无法添加该错误C# 如何创建WCF代理而不使用托管在windows应用程序中的svc文件,c#,wcf,metadata,app-config,C#,Wcf,Metadata,App Config,我有两个应用程序。一个是承载wcf服务的winform服务器端,另一个是winform客户端应用程序,我必须在其中添加服务引用。没有任何svc文件。因此,当我试图在winform wcf客户端创建服务代理时,只需输入如下url http://localhost:7998/WPFHost/ 或 网tcp://localhost:7997/WPFHost/用于通过服务引用添加服务,然后获取错误。 元数据包含无法解析的引用:'net。tcp://localhost:7997/WPFHost/“。 在这
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<services>
<service name="WCFService.Service"
behaviorConfiguration="behaviorConfig">
<host>
<baseAddresses>
<add baseAddress="net.tcp://localhost:7997/WPFHost/"/>
<add baseAddress="http://localhost:7998/WPFHost/"/>
</baseAddresses>
</host>
<endpoint address="tcp"
binding="netTcpBinding"
bindingConfiguration="tcpBinding"
contract="ServiceAssembly.IChat"/>
<endpoint address="net.tcp://localhost:7996/WPFHost/mex"
binding="mexTcpBinding"
contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="behaviorConfig">
<serviceMetadata httpGetEnabled="true" httpGetUrl=""/>
<serviceDebug includeExceptionDetailInFaults="true"/>
<serviceThrottling maxConcurrentCalls="100" maxConcurrentSessions="100"/>
</behavior>
</serviceBehaviors>
</behaviors>
<bindings>
<netTcpBinding>
<binding name="tcpBinding"
maxBufferSize="67108864"
maxReceivedMessageSize="67108864"
maxBufferPoolSize="67108864"
transferMode="Buffered"
closeTimeout="00:00:10"
openTimeout="00:00:10"
receiveTimeout="00:20:00"
sendTimeout="00:01:00"
maxConnections="100">
<security mode="None">
</security>
<readerQuotas maxArrayLength="67108864"
maxBytesPerRead="67108864"
maxStringContentLength="67108864"/>
<reliableSession enabled="true" inactivityTimeout="00:20:00"/>
</binding>
</netTcpBinding>
</bindings>
</system.serviceModel>
</configuration>
您应该尝试创建服务代理到位于端口7996的mex地址:
net.tcp://localhost:7996/WPFHost/mex
是的,但我也犯了同样的错误。在app.config文件中发现任何错误。在第一次运行windows防火墙之前,上面的配置对我有效,我接受它。我想创建代理。在这里,我尝试添加服务引用并将url放到网络中。tcp://localhost:7996/WPFHost/mex 然后service ref窗口会因为无法找到服务而出错。我只是不明白为什么会发生这种情况……我的服务类中没有svc文件。如果你知道任何窍门,请分享。谢谢。你认为你为什么需要svc文件?您只需要在应用程序中创建一个ServiceHost实例。启动应用程序将启动服务,这样wsdl将可用。也许你没有启动应用程序?所以你的意思是我必须先启动服务,然后我可以添加服务引用,在那里我可以给出我的服务的url,比如“net”。tcp://localhost:7996/WPFHost/mex" ? 我理解正确吗。但人们使用svcutil生成代理,而不首先启动服务。除了svcutil之外,还有其他工具可以生成我的服务的代理,我将只指向我的服务应用程序。请用信息引导。