我一直在尝试遵循this example(从网站上的链接或here下载源代码,但我仍然遇到一个似乎嵌入在例子
我的程序已经(在安装AppFabric的SDK和其他依赖后)如下:。在Azure上使用AppFabric ServiceBus实现可靠的角色间通信,IObserver模式
- 下载源
- 上的AppFabric创建服务命名空间
- 我通过一个工作者角色将项目导入到一个新的Windows Azure项目中,确保它全部编译并且默认的Worker Role Run()方法启动并运行。
- 将InterRoleCommunicationExtension.cs中的方法GetInterRoleCommunicationEndpoint与我的AppFabric服务命名空间(IssuerName和ServicePath保持默认值)中的ServiceNameSpace和IssuerSecret配置在一起。这是我自己的参数的一个硬连线。
- 将示例中“SampleWorkerRole.cs”文件的初始化逻辑复制/粘贴到我的项目的工作角色的OnStart()方法中
- 注释引用Tracemanager。*作为演示代码没有Tracemanager方法已经实现,它们对于这个测试的工作并不重要。这些参考文献中大约有7-10个(在整个解决方案中只需执行Find - >“Tracemanager”)。
- 构建成功。
- 在本地计算模拟器上运行。
当我运行这个测试,新InterRoleCommunicationExtension的初始化过程中(在角色间通信基础设施的第一块被初始化,this.interRoleCommunicator = new InterRoleCommunicationExtension();
),将引发一个错误:“值不能为空参数。名称:contractType“。
钻入这一点,我按照执行下降到ServiceBusHostFactory.cs下面的方法(从样品中的一个文件):public static Type GetServiceContract(Type serviceType) { Guard.ArgumentNotNull(serviceType, "serviceType");
Type[] serviceInterfaces = serviceType.GetInterfaces();
if (serviceInterfaces != null && serviceInterfaces.Length > 0)
{
foreach (Type serviceInterface in serviceInterfaces)
{
ServiceContractAttribute serviceContractAttr = FrameworkUtility.GetDeclarativeAttribute<ServiceContractAttribute>(serviceInterface);
if (serviceContractAttr != null)
{
return serviceInterface;
}
}
}
return null;
}
的的serviceType参数的名称属性设置为“IInterRoleCommunicationServiceContract”,这是该演示的一个类,它扩展了IObservable。到serviceType.GetInterfaces()的调用的返回“System.IObservable`1”接口,然后将其传递到FrameworkUtility.GetDeclarativeAttribute(serviceInterface);
,其具有以下的代码:
public static IList GetDeclarativeAttributes(Type type) where T : class { Guard.ArgumentNotNull(type, "type");
object[] customAttributes = type.GetCustomAttributes(typeof(T), true);
IList<T> attributes = new List<T>();
if (customAttributes != null && customAttributes.Length > 0)
{
foreach (object customAttr in customAttributes)
{
if (customAttr.GetType() == typeof(T))
{
attributes.Add(customAttr as T);
}
}
}
else
{
Type[] interfaces = type.GetInterfaces();
if (interfaces != null && interfaces.Length > 0)
{
foreach (object[] customAttrs in interfaces.Select(iface => iface.GetCustomAttributes(typeof(T), false)))
{
if (customAttrs != null && customAttrs.Length > 0)
{
foreach (object customAttr in customAttrs)
{
attributes.Add(customAttr as T);
}
}
}
}
}
return attributes;
}</code><br>
It is here that the issue arises. After not finding any customAttributes on the "IObservable1" type, it calls type.GetInterfaces(), expecting a return. Even though type is "System.IObservable
1“,则此方法返回一个空数组,这会导致函数返回null和上述消息异常提出
我非常感兴趣的是获得这个场景的工作,因为我认为发布/订阅消息范例是我的应用程序的完美解决方案。任何人都可以得到这个演示代码(来自AppFabric CAT团队本身!)工作,或者可以发现我的错误?谢谢你的帮助。
感谢您回到我的瓦列里。您的修订似乎在我的开发结构框中工作。当我在Azure上运行它时,我会在一两周后再次回到这里,并且能够看到它在多种情况下的运行情况。再次感谢你! – user483679 2011-02-21 15:38:31