我正在学习使用WCF路由服务可以做些什么.仍然在'拧紧它,看看它能做什么'阶段.
我对路由服务的理解是,当消息通过时,服务将尝试将其传递给备份列表中首先出现的任何端点.如果失败了,它将继续尝试下一个,然后是下一个,直到任何一个有效或者没有什么可以尝试.
我想做的是访问该失败事件,以便我可以:
无法找到如何扩展WCF框架以获取此特定事件.
这是WCF路由服务可以做的事情吗?任何朝着正确方向的推动都将非常感激.
目前,我在IIS下托管了30-beh动态生成的路由服务(或者更准确地说,是Visual Studio 2010的ASP.NET开发服务器).我正在设置Global.asax中服务的路由,如下所示.
protected void Application_Start(object sender, EventArgs e)
{
List<Type> serviceTypes = ServiceUtility.GetServiceTypes();
foreach (Type st in serviceTypes)
{
string route = String.Format("Services/{0}.svc", ServiceUtility.GetServiceName(st));
RouteTable.Routes.Add(new ServiceRoute(route, new RoutingServiceHostFactory(st), typeof(System.ServiceModel.Routing.RoutingService)));
}
}
Run Code Online (Sandbox Code Playgroud)
ServiceUtility和RoutingServiceHostFactory是自定义类.请注意,IPolicyService是我感兴趣的程序集中的WCF服务契约接口.
public static class ServiceUtility
{
public static List<Type> GetServiceTypes()
{
Type policyInterfaceType = typeof(IPolicyService);
Assembly serviceContractsAssembly = Assembly.GetAssembly(policyInterfaceType);
Type[] serviceContractsAssemblyTypes = serviceContractsAssembly.GetTypes();
List<Type> serviceTypes = new List<Type>();
foreach (Type t in serviceContractsAssemblyTypes)
{
if (!t.IsInterface)
continue;
object[] attrib = …Run Code Online (Sandbox Code Playgroud) 答案:我没有清理我的ConnectionPools.
解决的方案是:
建立:
测试:
拆除:
SqlConnection.ClearAllPools();原始问题在首页.
大家好
测试场景是:
建立:
测试:
拆除:
一切都很顺利,直到我进入TearDown阶段.我总是得到以下错误:
无法删除数据库"TEMP_NUnit",因为它当前正在使用中.
这让我感到困惑,因为我正在关闭(在finally语句中显式调用conn.Close)并正确地处理(通过using语句)我的所有DbConnection对象.在TearDown到来之前,"TEMP_NUnit"数据库中不应该有任何运行.
如果我关闭NUnit然后重新打开它,SetUp的第2步总是先行.
我不确定我在这里做错了什么.任何指向正确的方向将不胜感激.