私はこの例(サイトのリンクからソースコードをダウンロードするか、ここ)に従おうとしていますが、例に埋め込まれているように見えるエラーに遭遇し続けます.
私の手順は次のとおりです(AppFabric SDKなどをインストールした後)依存関係):
- ソースをダウンロード
- AppFabric にサービス名前空間を作成します。
- 1 つの Worker ロールを持つ新しい Windows Azure プロジェクトにプロジェクトをインポートし、すべてがコンパイルされ、デフォルトの Worker Role Run() メソッドが開始して機能することを確認します。
- InterRoleCommunicationExtension.cs のメソッド GetInterRoleCommunicationEndpoint を、AppFabric サービス名前空間の ServiceNameSpace と IssuerSecret で構成します (IssuerName と ServicePath はデフォルトのままです)。これは、私自身のパラメーターの配線です。
- デモの「SampleWorkerRole.cs」ファイルから初期化ロジックをコピーして、プロジェクトのワーカー ロールの OnStart() メソッドに貼り付けます。
- デモ コードには Tracemanager メソッドが実装されておらず、このテストが機能するために重要ではないため、Tracemanager.* への参照をコメント アウトします。これらの参照は約 7 ~ 10 個あります (ソリューション全体で [検索] -> [Tracemanager] を実行するだけです)。
- 正常にビルドします。
- ローカル コンピューティング エミュレーターで実行します。
このテストを実行すると、新しい InterRoleCommunicationExtension (初期化される役割間通信インフラストラクチャの最初の部分) の初期化中に、「値を null にすることはできません。パラメーター名: contractType.」this.interRoleCommunicator = new InterRoleCommunicationExtension();
というエラーが発生します。
これを少し掘り下げて、実行を ServiceBusHostFactory.cs (サンプルのファイルの 1 つ) の次のメソッドまでたどります。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 パラメータの Name プロパティは「IInterRoleCommunicationServiceContract」です。これはデモのクラスの 1 つであり、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 チーム自体から) 動作させることができた人はいますか? または、私のエラーを見つけることができますか? ご協力ありがとうございました。