我有一个使用 WCF 的简单服务器/客户端设置。我的问题是,由于连接服务器意外关闭,任何期望返回值的方法都会产生异常
所有数据类都在外部项目内MSO.ErrorSystem.Shared.Datatypes
调用该方法的代码:
using (var client = Util.GetSearchServiceClient())
{
ViewBag.Results = client.SearchReports(searchTerm, page, 50);
}
Util.GetSearchServiceClient()
:
public static SearchServiceClient GetSearchServiceClient()
{
SearchServiceClient client = new SearchServiceClient();
client.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
return client;
}
服务器端调用的方法:
public IEnumerable<Shared.Datatypes.Report> SearchReports(string pSearchterm, int pPageNum, int pPageSize)
{
using (var session = DatabaseManager.Instance.DocumentStore.OpenSession())
{
return session.Query<Report>().Where(r => Regex.IsMatch(r.Title, pSearchterm) || Regex.IsMatch(r.Text, pSearchterm))
.OrderBy(r => r.Open).OrderBy(r => r.LastEdited).Skip(pPageNum * pPageSize).Take(pPageSize);
}
}
编辑:有问题的例外