2015-11-19 202 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

相關問題