これを機能させるのに問題があります。
ハブが引数でジェネリックを処理するようにします。したがって、パラメーターの型は、具体的なジェネリック型によって実装される抽象クラスです。これは、ジェネリック メソッドを作成できない可能性があるためです。このような:
public void Process(MyAbstractClass arg)
しかし、クライアントに型情報をシリアル化するように指示すると、登録に失敗しました。
これは、クライアント (SignalR WinRT) のシリアル化構成です。
_hubConnecton.JsonSerializer = new JsonSerializer()
{
PreserveReferencesHandling = PreserveReferencesHandling.Objects,
TypeNameHandling = TypeNameHandling.Objects,
TypeNameAssemblyFormat = FormatterAssemblyStyle.Simple
};
これは、フィドラー トレースから取得したエラーです。
[JsonSerializationException]: Could not load assembly 'Microsoft.AspNet.SignalR.Client'.
at Newtonsoft.Json.Serialization.DefaultSerializationBinder.GetTypeFromTypeNameKey(TypeNameKey typeNameKey)
at Newtonsoft.Json.Utilities.ThreadSafeStore`2.AddValue(TKey key)
at Newtonsoft.Json.Utilities.ThreadSafeStore`2.Get(TKey key)
at Newtonsoft.Json.Serialization.DefaultSerializationBinder.BindToType(String assemblyName, String typeName)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.ReadSpecialProperties(JsonReader reader, Type& objectType, JsonContract& contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue, Object& newValue, String& id)
[JsonSerializationException]: Error resolving type specified in JSON 'Microsoft.AspNet.SignalR.Client.Hubs.HubRegistrationData, Microsoft.AspNet.SignalR.Client'. Path '[0].$type', line 1, position 111.
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.ReadSpecialProperties(JsonReader reader, Type& objectType, JsonContract& contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue, Object& newValue, String& id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateObject(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.PopulateList(IWrappedCollection wrappedList, JsonReader reader, JsonArrayContract contract, JsonProperty containerProperty, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateList(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, Object existingValue, String id)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.CreateValueInternal(JsonReader reader, Type objectType, JsonContract contract, JsonProperty member, JsonContainerContract containerContract, JsonProperty containerMember, Object existingValue)
at Newtonsoft.Json.Serialization.JsonSerializerInternalReader.Deserialize(JsonReader reader, Type objectType, Boolean checkAdditionalContent)
at Newtonsoft.Json.JsonSerializer.DeserializeInternal(JsonReader reader, Type objectType)
at Newtonsoft.Json.JsonSerializer.Deserialize(JsonReader reader, Type objectType)
at Newtonsoft.Json.JsonSerializer.Deserialize(TextReader reader, Type objectType)
at Microsoft.AspNet.SignalR.Json.JsonNetSerializer.Parse(TextReader reader, Type targetType)
at Microsoft.AspNet.SignalR.Json.JsonSerializerExtensions.Parse[T](IJsonSerializer serializer, String json)
at Microsoft.AspNet.SignalR.Hubs.HubDispatcher.AuthorizeRequest(IRequest request)
at Microsoft.AspNet.SignalR.PersistentConnection.Authorize(IRequest request)
at Microsoft.AspNet.SignalR.Owin.CallHandler.Invoke(IDictionary`2 environment)
at Microsoft.AspNet.SignalR.Owin.Handlers.HubDispatcherHandler.Invoke(IDictionary`2 environment)
at Microsoft.Owin.Host.SystemWeb.OwinCallContext.Execute()
at Microsoft.Owin.Host.SystemWeb.OwinHttpHandler.BeginProcessRequest(HttpContextBase httpContext, AsyncCallback callback, Object extraData)
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at Microsoft.Owin.Host.SystemWeb.Infrastructure.ErrorState.Rethrow()
at Microsoft.Owin.Host.SystemWeb.CallContextAsyncResult.End(IAsyncResult result)
at Microsoft.Owin.Host.SystemWeb.OwinHttpHandler.EndProcessRequest(IAsyncResult result)
at System.Web.HttpApplication.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute()
at System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously)
どうやら、登録中に型情報を送信するため、上記のエラーがスローされます
GET http://127.0.0.1:81/signalr/connect?transport=serverSentEvents&connectionToken=JKbyIAOOvt5BYGu_Ly2Yk9dNYVR7B180TobrrJpc5BYN5-DxdSwXs6i71pF0nJrLC3C7kaB-4VwD8Lu76vgVbIoWLE5Ux42GhJOJ_REslxuvo0bcCkbvf3rfki3Rk6TJ0&connectionData=[%7B%22$id%22:%221%22,%22$type%22:%22Microsoft. AspNet.SignalR.Client.Hubs.HubRegistrationData,%20Microsoft.AspNet.SignalR.Client%22,%22Name%22:%22BusGatewayHub%22%7D] HTTP/1.1
次の行TypeNameHandling = TypeNameHandling.Objects
をに変更すると、抽象型であるためインスタンス化できないTypeNameHandling = TypeNameHandling.Auto
というエラーが表示されます。MyAbstractClass
シリアル化を手動で処理する必要があるように思えますが、できればそれを避けています。
考え?