2015-11-19 163 views
0

上下文

我有一个使用Xamarin的大型跨平台项目。因为我在这个项目上工作很多,最近我们需要更多的WPF和Windows 10客户端,所以我完全专注于这些,而忽略了Android客户端。 (是不要告诉我这是很糟糕的,我知道... :-))创建EventWaitHandle时会导致NotSupportedException的原因是什么?

例外

不过,现在我工作了一遍,试图让它运行起来,但我一直在便携式类库的代码中获取System.NotSupportedException,其中创建新的EventWaitHandle

// The next line throws the System.NotSupportedException: Operation is not supported. 
new EventWaitHandle(false, EventResetMode.ManualReset, module.Identifier.ToString()); // module.Identifier is a GUID (it's valid) 

这个代码是一些个月大,在WPF工作得很好,和Windows 10的客户,所以我想也许EventWaitHandle s的不Xamarin的Android的支持,但我无法找到任何证据。相反的情况似乎是这样的:它是well documented

如果有帮助(它并没有帮助我很多......)这里是异常的完整堆栈跟踪:

11-19 19:18:27.290 I/MonoDroid(26568): UNHANDLED EXCEPTION: 
11-19 19:18:27.290 I/MonoDroid(26568): System.NotSupportedException: Operation is not supported. 
11-19 19:18:27.290 I/MonoDroid(26568): at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() <IL 0x00011, 0x00078> 
11-19 19:18:27.290 I/MonoDroid(26568): at System.Runtime.CompilerServices.AsyncMethodBuilderCore.<ThrowAsync>m__0 (object) <IL 0x00006, 0x0006b> 
11-19 19:18:27.290 I/MonoDroid(26568): at Android.App.SyncContext/<Post>c__AnonStorey0.<>m__0() [0x00000] in /Users/builder/data/lanes/2185/53fce373/source/monodroid/src/Mono.Android/src/Android.App/SyncContext.cs:18 
11-19 19:18:27.290 I/MonoDroid(26568): at Java.Lang.Thread/RunnableImplementor.Run() [0x0000b] in /Users/builder/data/lanes/2185/53fce373/source/monodroid/src/Mono.Android/src/Java.Lang/Thread.cs:36 
11-19 19:18:27.290 I/MonoDroid(26568): at Java.Lang.IRunnableInvoker.n_Run (intptr,intptr) [0x00009] in /Users/builder/data/lanes/2185/53fce373/source/monodroid/src/Mono.Android/platforms/android-19/src/generated/Java.Lang.IRunnable.cs:71 
11-19 19:18:27.290 I/MonoDroid(26568): at (wrapper dynamic-method) object.c26750eb-eb85-45fe-a488-c6d12c1aaf0e (intptr,intptr) <IL 0x00011, 0x0003b> 
11-19 19:18:27.315 W/art  (26568): JNI RegisterNativeMethods: attempt to register 0 native methods for md52ce486a14f4bcd95899665e9d932190b.JavaProxyThrowable 
11-19 19:18:27.320 D/AndroidRuntime(26568): Shutting down VM 
An unhandled exception occured. 

11-19 19:18:28.190 E/AndroidRuntime(26568): FATAL EXCEPTION: main 
11-19 19:18:28.190 E/AndroidRuntime(26568): Process: de.msm.IDS, PID: 26568 
11-19 19:18:28.190 E/AndroidRuntime(26568): java.lang.RuntimeException: java.lang.reflect.InvocationTargetException 
11-19 19:18:28.190 E/AndroidRuntime(26568):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1194) 
11-19 19:18:28.190 E/AndroidRuntime(26568): Caused by: java.lang.reflect.InvocationTargetException 
11-19 19:18:28.190 E/AndroidRuntime(26568):  at java.lang.reflect.Method.invoke(Native Method) 
11-19 19:18:28.190 E/AndroidRuntime(26568):  at java.lang.reflect.Method.invoke(Method.java:372) 
11-19 19:18:28.190 E/AndroidRuntime(26568):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1399) 
11-19 19:18:28.190 E/AndroidRuntime(26568):  ... 1 more 
11-19 19:18:28.190 E/AndroidRuntime(26568): Caused by: md52ce486a14f4bcd95899665e9d932190b.JavaProxyThrowable: System.NotSupportedException: Operation is not supported. 
11-19 19:18:28.190 E/AndroidRuntime(26568): at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw() <IL 0x00011, 0x00078> 
11-19 19:18:28.190 E/AndroidRuntime(26568): at System.Runtime.CompilerServices.AsyncMethodBuilderCore.<ThrowAsync>m__0 (object) <IL 0x00006, 0x0006b> 
11-19 19:18:28.190 E/AndroidRuntime(26568): at Android.App.SyncContext/<Post>c__AnonStorey0.<>m__0() [0x00000] in /Users/builder/data/lanes/2185/53fce373/source/monodroid/src/Mono.Android/src/Android.App/SyncContext.cs:18 
11-19 19:18:28.190 E/AndroidRuntime(26568): at Java.Lang.Thread/RunnableImplementor.Run() [0x0000b] in /Users/builder/data/lanes/2185/53fce373/source/monodroid/src/Mono.Android/src/Java.Lang/Thread.cs:36 
11-19 19:18:28.190 E/AndroidRuntime(26568): at Java.Lang.IRunnableInvoker.n_Run (intptr,intptr) [0x00009] in /Users/builder/data/lanes/2185/53fce373/source/monodroid/src/Mono.Android/platforms/android-19/src/generated/Java.Lang.IRunnable.cs:71 
11-19 19:18:28.190 E/AndroidRuntime(26568): at (wrapper dynamic-method) object.c26750eb-eb85-45fe-a488-c6d12c1aaf0e (intptr,intptr) <IL 0x00011, 0x0003b> 
11-19 19:18:28.190 E/AndroidRuntime(26568): 
11-19 19:18:28.190 E/AndroidRuntime(26568):  at mono.java.lang.RunnableImplementor.n_run(Native Method) 
11-19 19:18:28.190 E/AndroidRuntime(26568):  at mono.java.lang.RunnableImplementor.run(RunnableImplementor.java:29) 
11-19 19:18:28.190 E/AndroidRuntime(26568):  at android.os.Handler.handleCallback(Handler.java:739) 
11-19 19:18:28.190 E/AndroidRuntime(26568):  at android.os.Handler.dispatchMessage(Handler.java:95) 
11-19 19:18:28.190 E/AndroidRuntime(26568):  at android.os.Looper.loop(Looper.java:145) 
11-19 19:18:28.190 E/AndroidRuntime(26568):  at android.app.ActivityThread.main(ActivityThread.java:6126) 
11-19 19:18:28.190 E/AndroidRuntime(26568):  ... 4 more  

项目细节

Android的项目被设置为使用API等级19:

Android project setup: using API Level 19

的PCL目标包括课程的.NET Framework 4.5和Xamarin.Android:

PCL targets

我主要使用用于调试的目标硬件设备是Samsung SM-P900Android 5.0.2

什么可能会导致这种异常在Android(但不是在Windows中)?

+0

什么是完整的异常堆栈? – CathalMF

回答

1

看单(Xamarin).NET实现: https://github.com/mono/mono/blob/master/mcs/class/corlib/System.Threading/EventWaitHandle.cs

的EventWaitHandle不单支持。

public EventWaitHandle (bool initialState, EventResetMode mode, string name) 
    { 
     throw new NotSupportedException(); 
    } 
+0

LOL就这么简单?谢谢! – markus

+0

本来很高兴在Xamarin文档中提到它,你不觉得吗? – markus

+0

是的,我同意。这里有单声道实现:https://github.com/mosa/Mono-Class-Libraries/blob/master/mcs/class/corlib/System.Threading/EventWaitHandle.cs 也许你可以使用这些。 – patryk9200

相关问题