总结下在mono环境中使用Wcf出现的问题以帮助你快速解决问题。

1.昨天在内网Centos7下部署由Windows上开发完成的ASP.NET Mvc4项目,部署到mono环境下遇到了无法找到endpoint address,然后楼主查阅资料最后写了一个代理类解决,总结的问题:mono下无法识别web.config中的address

代理类

   /// <summary>
/// WCF代理客户端
/// </summary>
public class TWCFProxClient
{
/// <summary>
/// Service1Client
/// </summary>
/// <returns></returns>
public static Service1Client Service1Client_BasicHttpBinding()
{
var result = BasicHttpBinding("BasicHttpBinding_IService1", "urlAddress");
return new Service1Client(result.Item1, result.Item2);
} /// <summary>
/// 创建一个RemoteAddress
/// </summary>
/// <returns></returns>
private static Tuple<BasicHttpBinding, EndpointAddress> BasicHttpBinding(string configurationName, string uri)
{
var basicbinding = new BasicHttpBinding(configurationName);
var remoteAddress = new EndpointAddress(uri);
return Tuple.Create(basicbinding, remoteAddress);
}
05-06 07:07