我试图将服务引用添加到已经创建了另一个引用的项目中。我复制了那些项目中使用的App.Config和Web.configs,并将它们改编为我想要添加的服务。我也复制并修改了合同,我相信我做得很好。
所以我的问题是:您认为在添加服务参考或同样有用的地方我可能做错了什么或常见错误在哪里以及如何解决有关添加服务错误的问题引用具有mex端点的项目?
错误
错误详细
有条件的信息:
合同只作为一项操作("开始")。
正在通过net.tcp进行连接。
服务和对象是不同的项目。
Object有一个App.Config,Service有一个Web.Config
更新
服务网站.Config
<?xml version="1.0"?>
<configuration>
<system.diagnostics>
<sources>
<source name="System.ServiceModel" switchValue="Information, ActivityTracing" propagateActivity="true">
<listeners>
<add name="traceListener" type="System.Diagnostics.XmlWriterTraceListener" initializeData="C:\inetpub\SocketListener\logs\Traces.svclog" />
</listeners>
</source>
</sources>
</system.diagnostics>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5.1" />
</system.web>
<system.serviceModel>
<services>
<service name="SocketListener.SocketListener">
<endpoint address="" binding="netTcpBinding" contract="SocketListener.ISocketListener">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexTcpBinding" bindingConfiguration="" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="net.tcp://<IP>/SocketListener/SocketListener.svc" />
</baseAddresses>
</host>
</service>
</services>
<bindings>
<netTcpBinding>
<binding name="netTcpBindingConf" closeTimeout="00:10:00" openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:05:00" hostNameComparisonMode="StrongWildcard" transactionFlow="false" transferMode="Buffered" maxBufferPoolSize="20000000"
maxBufferSize="20000000"
maxConnections="20000000"
maxReceivedMessageSize="20000000"
portSharingEnabled="true"
listenBacklog="20000000">
</binding>
</netTcpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="">
<serviceMetadata httpGetEnabled="false" httpsGetEnabled="false" />
<serviceDebug includeExceptionDetailInFaults="false" />
<serviceThrottling maxConcurrentCalls="200" maxConcurrentSessions="200" maxConcurrentInstances="200" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.1" />
</startup>
</configuration>
答案 0 :(得分:0)
尝试将behaviorConfiguration添加到服务:
<?xml version="1.0"?>
<configuration>
<system.diagnostics>
<sources>
<source name="System.ServiceModel" switchValue="Information, ActivityTracing" propagateActivity="true">
<listeners>
<add name="traceListener" type="System.Diagnostics.XmlWriterTraceListener" initializeData="C:\inetpub\SocketListener\logs\Traces.svclog" />
</listeners>
</source>
</sources>
</system.diagnostics>
<appSettings>
<add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" />
</appSettings>
<system.web>
<compilation debug="true" targetFramework="4.5.1" />
</system.web>
<system.serviceModel>
<services>
<service name="SocketListener.SocketListener" behaviorConfiguration="ServiceBeh">
<endpoint address="" binding="netTcpBinding" contract="SocketListener.ISocketListener">
<identity>
<dns value="localhost" />
</identity>
</endpoint>
<endpoint address="mex" binding="mexTcpBinding" bindingConfiguration="" contract="IMetadataExchange" />
<host>
<baseAddresses>
<add baseAddress="net.tcp://<IP>/SocketListener/SocketListener.svc" />
</baseAddresses>
</host>
</service>
</services>
<bindings>
<netTcpBinding>
<binding name="netTcpBindingConf" closeTimeout="00:10:00" openTimeout="00:10:00" receiveTimeout="00:10:00" sendTimeout="00:05:00" hostNameComparisonMode="StrongWildcard" transactionFlow="false" transferMode="Buffered" maxBufferPoolSize="20000000"
maxBufferSize="20000000"
maxConnections="20000000"
maxReceivedMessageSize="20000000"
portSharingEnabled="true"
listenBacklog="20000000">
</binding>
</netTcpBinding>
</bindings>
<behaviors>
<serviceBehaviors>
<behavior name="ServiceBeh">
<serviceMetadata httpGetEnabled="false" httpsGetEnabled="false" />
<serviceDebug includeExceptionDetailInFaults="false" />
<serviceThrottling maxConcurrentCalls="200" maxConcurrentSessions="200" maxConcurrentInstances="200" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.1" />
</startup>
</configuration>
答案 1 :(得分:0)
此错误是由文件* .svc的配置错误和IIS中的未命中配置
引起的档案错误配置
<强>错误强>
<%@ ServiceHost Language="C#" Debug="true" Service="Service" %>
<强>正确强>
<%@ ServiceHost Language="C#" Debug="true" Service="<Namespace>.<Class used in the Service>" %>
IIS MissConfiguration
<强>错误强>
在IIS中部署的应用程序中, 在高级设置中, 我在启用的协议
中有 http更正
在IIS中部署的应用程序中, 在高级设置中, 我在启用的协议
中更改为 net.tcp