运行SignalR自主机样本会引发最新的mono dev分支异常

时间:2015-02-02 22:37:23

标签: linux mono signalr

在Linux上使用Mono,在https://github.com/SignalR/SignalR找到的示例Microsoft.AspNet.SignalR.Mono似乎使用单声道的稳定版本,但没有使用最新的开发分支(3.99)。有谁遇到过这个?我得到以下异常:

Unhandled Exception:
System.Reflection.TargetInvocationException: Exception has been thrown by the
target of an invocation. ---> System.InvalidProgramException: Invalid IL code
in (wrapper delegate-invoke)
<Module>:invoke_callvirt_CancellationTokenRegistration_CancellationToken&_Action`1<object>_object
(System.Threading.CancellationToken&,System.Action`1<object>,object): IL_004f:
castclass 0x00000007


  at
Microsoft.AspNet.SignalR.Infrastructure.CancellationTokenExtensions.SafeRegister
(CancellationToken cancellationToken, System.Action`1 callback, System.Object
state) [0x00000] in <filename unknown>:0 
  at
Microsoft.AspNet.SignalR.Hosting.HostDependencyResolverExtensions.InitializeResolverDispose
(IDependencyResolver resolver, CancellationToken hostShutdownToken) [0x00000]
in <filename unknown>:0 
  at
Microsoft.AspNet.SignalR.Hosting.HostDependencyResolverExtensions.InitializeHost
(IDependencyResolver resolver, System.String instanceName, CancellationToken
hostShutdownToken) [0x00000] in <filename unknown>:0 
  at Owin.OwinExtensions.UseSignalRMiddleware[PersistentConnectionMiddleware]
(IAppBuilder builder, System.Object[] args) [0x00000] in <filename unknown>:0 
  at Owin.OwinExtensions.RunSignalR (IAppBuilder builder, System.Type
connectionType, Microsoft.AspNet.SignalR.ConnectionConfiguration configuration)
[0x00000] in <filename unknown>:0 
  at Owin.OwinExtensions.RunSignalR[RawConnection] (IAppBuilder builder,
Microsoft.AspNet.SignalR.ConnectionConfiguration configuration) [0x00000] in
<filename unknown>:0 
  at Owin.OwinExtensions.RunSignalR[RawConnection] (IAppBuilder builder)
[0x00000] in <filename unknown>:0 
  at Microsoft.AspNet.SelfHost.Samples.Startup.<Configuration>b__0 (IAppBuilder
map) [0x00000] in <filename unknown>:0 
  at Owin.MapExtensions.Map (IAppBuilder app, PathString pathMatch,
System.Action`1 configuration) [0x00000] in <filename unknown>:0 
  at Owin.MapExtensions.Map (IAppBuilder app, System.String pathMatch,
System.Action`1 configuration) [0x00000] in <filename unknown>:0 
  at Microsoft.AspNet.SelfHost.Samples.Startup.Configuration (IAppBuilder app)
[0x00000] in <filename unknown>:0 
  at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke
(System.Reflection.MonoMethod,object,object[],System.Exception&)
  at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags
invokeAttr, System.Reflection.Binder binder, System.Object[] parameters,
System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0 
  --- End of inner exception stack trace ---
  at System.Reflection.MonoMethod.Invoke (System.Object obj, BindingFlags
invokeAttr, System.Reflection.Binder binder, System.Object[] parameters,
System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0 
  at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[]
parameters) [0x00000] in <filename unknown>:0 
  at Owin.Loader.DefaultLoader+<>c__DisplayClass12.<MakeDelegate>b__b
(IAppBuilder builder) [0x00000] in <filename unknown>:0 
  at Owin.Loader.DefaultLoader+<>c__DisplayClass1.<LoadImplementation>b__0
(IAppBuilder builder) [0x00000] in <filename unknown>:0 
  at Microsoft.Owin.Hosting.Engine.HostingEngine.ResolveApp
(Microsoft.Owin.Hosting.Engine.StartContext context) [0x00000] in <filename
unknown>:0 
  at Microsoft.Owin.Hosting.Engine.HostingEngine.Start
(Microsoft.Owin.Hosting.Engine.StartContext context) [0x00000] in <filename
unknown>:0 
  at Microsoft.Owin.Hosting.Starter.DirectHostingStarter.Start
(Microsoft.Owin.Hosting.StartOptions options) [0x00000] in <filename unknown>:0 
  at Microsoft.Owin.Hosting.Starter.HostingStarter.Start
(Microsoft.Owin.Hosting.StartOptions options) [0x00000] in <filename unknown>:0 
  at Microsoft.Owin.Hosting.WebApp.StartImplementation (IServiceProvider
services, Microsoft.Owin.Hosting.StartOptions options) [0x00000] in <filename
unknown>:0 
  at Microsoft.Owin.Hosting.WebApp.Start (Microsoft.Owin.Hosting.StartOptions
options) [0x00000] in <filename unknown>:0 
  at Microsoft.Owin.Hosting.WebApp.Start[Startup]
(Microsoft.Owin.Hosting.StartOptions options) [0x00000] in <filename unknown>:0 
  at Microsoft.Owin.Hosting.WebApp.Start[Startup] (System.String url) [0x00000]
in <filename unknown>:0 
  at Microsoft.AspNet.SelfHost.Samples.Program.Main (System.String[] args)
[0x00000] in <filename unknown>:0 
[ERROR] FATAL UNHANDLED EXCEPTION: System.Reflection.TargetInvocationException:
Exception has been thrown by the target of an invocation. --->
System.InvalidProgramException: Invalid IL code in (wrapper delegate-invoke)
<Module>:invoke_callvirt_CancellationTokenRegistration_CancellationToken&_Action`1<object>_object
(System.Threading.CancellationToken&,System.Action`1<object>,object): IL_004f:
castclass 0x00000007

3 个答案:

答案 0 :(得分:1)

这看起来像Mono的更高版本中的错误。我星期五报告了这个问题:http://bugzilla.xamarin.com/show_bug.cgi?id=29665

答案 1 :(得分:0)

已在SignalIR repo上报告该问题。尝试拉开最新版本的dev分支,ASP.NET团队已经注释掉了抛出异常的代码作为现在的解决方法。

答案 2 :(得分:0)

如果IsRunningMono为true,我最终选择在Re​​solveRegisterDelegate()中返回回退寄存器:

if (MonoUtility.IsRunningMono)
    return fallback;

try
{
    methodInfo = typeof(CancellationToken).GetMethod("InternalRegisterWithoutEC",
                                                             BindingFlags.NonPublic | BindingFlags.Instance,
                                                             binder: null,
                                                             types: new[] { typeof(Action<object>), typeof(object) },
                                                             modifiers: null);

}
catch
{
    // Swallow this exception. Being extra paranoid, we don't want anything to break in case this dirty
    // reflection hack fails for any reason
}

我注意到这发生在单声道早期稳定版本中,因为GetMethod(&#34; InternalRegisterWithoutEC&#34;)返回null并且没有返回带有最新dev单声道分支的null。