.net 使用Mex时出现问题
我的应用程序同时使用NetTcpBinding和BasicHttpBinding,但它们都将公开我的服务类的一个子集。我已经创建了如下服务 问题是,尽管我刚刚将3个合同添加到Mex绑定中,但当我想将服务添加到项目中时,所有合同都会显示出来.net 使用Mex时出现问题,.net,wcf,.net,Wcf,我的应用程序同时使用NetTcpBinding和BasicHttpBinding,但它们都将公开我的服务类的一个子集。我已经创建了如下服务 问题是,尽管我刚刚将3个合同添加到Mex绑定中,但当我想将服务添加到项目中时,所有合同都会显示出来 m_ServiceHost = new ServiceHost(typeof(Services), baseAddresses); BasicHttpBinding basicHttpBinding = new BasicHttpBinding(); b
m_ServiceHost = new ServiceHost(typeof(Services), baseAddresses);
BasicHttpBinding basicHttpBinding = new BasicHttpBinding();
basicHttpBinding.UseDefaultWebProxy = false;
m_ServiceHost.AddServiceEndpoint(typeof( IMyFirstService), basicHttpBinding, "MyFirstService");
m_ServiceHost.AddServiceEndpoint(typeof(IMySecondService), basicHttpBinding, "MySecondService");
m_ServiceHost.AddServiceEndpoint(typeof(IMyThirdService), basicHttpBinding, "MyThirdService");
NetTcpBinding netTcpBinding = new NetTcpBinding();
netTcpBinding.MaxReceivedMessageSize = 2147483647;
netTcpBinding.ReaderQuotas.MaxNameTableCharCount = 2147483647;
m_ServiceHost.AddServiceEndpoint(typeof(IMyFirstService), netTcpBinding, "MyFirstService");
m_ServiceHost.AddServiceEndpoint(typeof(IMySecondService), netTcpBinding, "MySecondService");
m_ServiceHost.AddServiceEndpoint(typeof(IMyFourthService), netTcpBinding, "MyFourthService");
m_ServiceHost.AddServiceEndpoint(typeof(IMyFifthService), netTcpBinding, "MyFifthService");
m_ServiceHost.AddServiceEndpoint(typeof(IMySixService), netTcpBinding, "MySixService");
HttpTransportBindingElement httpTransport = new HttpTransportBindingElement();
httpTransport.MaxReceivedMessageSize = 2147483647;
httpTransport.MaxBufferSize = 2147483647;
TextMessageEncodingBindingElement textMessageEncoding = new TextMessageEncodingBindingElement();
textMessageEncoding.ReaderQuotas.MaxDepth = 2147483647;
textMessageEncoding.ReaderQuotas.MaxStringContentLength = 2147483647;
textMessageEncoding.ReaderQuotas.MaxArrayLength = 2147483647;
textMessageEncoding.ReaderQuotas.MaxBytesPerRead = 2147483647;
textMessageEncoding.ReaderQuotas.MaxNameTableCharCount = 2147483647;
System.ServiceModel.Channels.CustomBinding mexHttpCustomBinding = new System.ServiceModel.Channels.CustomBinding(textMessageEncoding, httpTransport);
mexHttpCustomBinding.Name = "MexHttpBindingConfig";
m_ServiceHost.AddServiceEndpoint(typeof(System.ServiceModel.Description.IMetadataExchange), mexHttpCustomBinding, "mex");
m_ServiceHost.Open();
我认为实现这一点的唯一方法是创建两个独立的服务主机。一个用于通过http公开的服务,另一个用于通过net.tcp绑定公开的服务 完成了。原始问题只是链接到了。@Adam:做得好。今天早上我太快就失去耐心了。