I'm making an android app with Xamarin.Forms. My iOS app is already finished and released.
My android version will not stop throwing multiple exceptions.
The first exception is a NullReferenceException. This breaks on the following code snipped:
handler(this, new PropertyChangedEventArgs(propertyName));
This is inside my OnPropertyChanged method in a custom NotifyBase class I use for my models.
(Also failing if i remove all but this line from the method.)
The debug output just tells me this:
System.NullReferenceException: Object reference not set to an instance of an object
An unhandled exception occured.
Exception:
This is followed by a TargetInvocationException giving this stack trace:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
07-16 17:37:47.916 I/MonoDroid(27212): UNHANDLED EXCEPTION: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object
07-16 17:37:47.916 I/MonoDroid(27212):07-16 17:37:47.916 I/MonoDroid(27212): at Xamarin.Forms.Forms+AndroidPlatformServices.BeginInvokeOnMainThread (System.Action action) [0x00000] in <filename unknown>:0
07-16 17:37:47.916 I/MonoDroid(27212): at Xamarin.Forms.Device.BeginInvokeOnMainThread (System.Action action) [0x00000] in <filename unknown>:0
07-16 17:37:47.916 I/MonoDroid(27212): at Xamarin.Forms.BindingExpression+BindingExpressionPart.PropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs args) [0x00000] in <filename unknown>:0
07-16 17:37:47.916 I/MonoDroid(27212): at (wrapper delegate-invoke) <Module>:invoke_void__this___object_PropertyChangedEventArgs (object,System.ComponentModel.PropertyChangedEventArgs)
07-16 17:37:47.916 I/MonoDroid(27212): at (wrapper delegate-invoke) <Module>:invoke_void__this___object_PropertyChangedEventArgs (object,System.ComponentModel.PropertyChangedEventArgs)
07-16 17:37:47.916 I/MonoDroid(27212): at TransMission.Mobile.Helper.NotifyBase.OnPropertyChanged (System.String propertyName) [0x00087] in c:\Users\Frederik.TECNO\Documents\Visual Studio 2012\Projects\TransMission\TransMission.Mobile\TransMission.Mobile\Helper\NotifyBase.cs:68
07-16 17:37:47.916 I/MonoDroid(27212): at TransMission.Mobile.Helper.NotifyBase.SetField[DateTime] (System.DateTime& field, DateTime value, System.String propertyName) [0x000a2] in c:\Users\Frederik.TECNO\Documents\Visual Studio 2012\Projects\TransMission\TransMission.Mobile\TransMission.Mobile\Helper\NotifyBase.cs:102
07-16 17:37:47.916 I/MonoDroid(27212): at TransMission.Mobile.Core.TransMissionCore.set_Date (DateTime value) [0x00001] in c:\Users\Frederik.TECNO\Documents\Visual Studio 2012\Projects\TransMission\TransMission.Mobile\TransMission.Mobile\Core\TransMissionCore.cs:275
07-16 17:37:47.916 I/MonoDroid(27212): at (wrapper managed-to-native) System.Reflection.MonoMethod:InternalInvoke (System.Reflection.MonoMethod,object,object[],System.Exception&)
07-16 17:37:47.916 I/MonoDroid(27212): 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
07-16 17:37:47.916 I/MonoDroid(27212): --- End of inner exception stack trace ---
07-16 17:37:47.916 I/MonoDroid(27212): at System.Reflection.MonoMethod.Invoke (object,System.Reflection.BindingFlags,System.Reflection.Binder,object[],System.Globalization.CultureInfo) <IL 0x00062, 0x0033c>
07-16 17:37:47.916 I/MonoDroid(27212): at Xamarin.Forms.BindingExpression.ApplyCore (object,Xamarin.Forms.BindableObject,Xamarin.Forms.BindableProperty,bool) <IL07-16 17:37:47.916 I/MonoDroid(27212): at System.Reflection.MethodBase.Invoke (object,object[]) <IL 0x00006, 0x0008f>
07-16 17:37:47.916 I/MonoDroid(27212): at Xamarin.Forms.BindingExpression.ApplyCore (object,Xamarin.Forms.BindableObject,Xamarin.Forms.BindableProperty,bool) <IL 0x00295, 0x0162f>
07-16 17:37:47.916 I/MonoDroid(27212): at Xamarin.Forms.BindingExpression.Apply (bool) <IL 0x00041, 0x0018b>
07-16 17:37:47.916 I/MonoDroid(27212): at Xamarin.Forms.Binding.Apply (bool) <IL 0x00027, 0x00113>
07-16 17:37:47.916 I/MonoDroid(27212): at Xamarin.Forms.BindableObject/<>c__DisplayClass1.<SetValueCore>b__0 () <IL 0x00100, 0x00493>
07-16 17:37:47.916 I/MonoDroid(27212): at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty,object,bool,bool,bool) <IL 0x001b4, 0x009d3>
07-16 17:37:47.916 I/MonoDroid(27212): at Xamarin.Forms.BindingExpression.ApplyCore (object,Xamarin.Forms.BindableObject,Xamarin.Forms.BindableProperty,bool) <IL 0x001f1, 0x011db>
07-16 17:37:47.916 I/MonoDroid(27212): at Xamarin.Forms.BindingExpression.Apply (object,Xamarin.Forms.BindableObject,Xamarin.Forms.BindableProperty) <IL 0x0007e, 0x003bf>
07-16 17:37:47.916 I/MonoDroid(27212): at Xamarin.Forms.Binding.Apply (object,Xamarin.Forms.BindableObject,Xamarin.Forms.BindableProperty) <IL 0x0004d, 0x00237>
07-16 17:37:47.916 I/MonoDroid(27212): at Xamarin.Forms.BindableObject.ApplyBindings (object) <IL 0x0003a, 0x002af>
07-16 17:37:47.916 I/MonoDroid(27212): at Xamarin.Forms.BindableObject.SetInheritedBindingContext (Xamarin.Forms.BindableObject,object) <IL 0x00056, 0x0029b>
07-16 17:37:47.916 I/MonoDroid(27212): at Xamarin.Forms.Element.OnBindingContextChanged () <IL 0x0001c, 0x00157>
07-16 17:37:47.916 I/MonoDroid(27212): at Xamarin.Forms.View.OnBindingContextChanged () <IL 0x0003b, 0x002a3>
07-16 17:37:47.916 I/MonoDroid(27212): at Xamarin.Forms.BindableObject.SetInheritedBindingContext (Xamarin.Forms.BindableObject,object) <IL 0x0005c, 0x002bf>
07-16 17:37:47.916 I/MonoDroid(27212): at Xamarin.Forms.Element.set_Parent (Xamarin.Forms.Element) <IL 0x00020, 0x00107>
07-16 17:37:47.916 I/MonoDroid(27212): at Xamarin.Forms.Element.OnChildAdded (Xamarin.Forms.Element) <IL 0x00002, 0x00053>
07-16 17:37:47.916 I/MonoDroid(27212): at Xamarin.Forms.Page.OnInternalAdded (Xamarin.Forms.VisualElement) <IL 0x00015, 0x000bf>
07-16 17:37:47.916 I/MonoDroid(27212): at Xamarin.Forms.Page.InternalChildrenOnCollectionChanged (object,System.Collections.Specialized.NotifyCollectionC
Unhandled Exception:
Again followed by a TargetInvocationException giving this stack trace:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
07-16 17:41:19.182 E/mono (27212):
07-16 17:41:19.182 E/mono (27212): Unhandled Exception:
07-16 17:41:19.182 E/mono (27212): at (wrapper delegate-invoke) <Module>:invoke_void__this___object_PropertyChangedEventArgs (object,System.Compon07-16 17:41:19.182 E/mono (27212): System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object
07-16 17:41:19.182 E/mono (27212): at Xamarin.Forms.Forms+AndroidPlatformServices.BeginInvokeOnMainThread (System.Action action) [0x00000] in <filename unknown>:0
07-16 17:41:19.182 E/mono (27212): at Xamarin.Forms.Device.BeginInvokeOnMainThread (System.Action action) [0x00000] in <filename unknown>:0
07-16 17:41:19.182 E/mono (27212): at Xamarin.Forms.BindingExpression+BindingExpressionPart.PropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs args) [0x00000] in <filename unknown>:0
07-16 17:41:19.182 E/mono (27212): at (wrapper delegate-invoke) <Module>:invoke_void__this___object_PropertyChangedEventArgs (object,System.ComponentModel.PropertyChangedEventArgs)
07-16 17:41:19.182 E/mono (27212): at (wrapper delegate-invoke) <Module>:invoke_void__this___object_PropertyChangedEventArgs (object,System.ComponentModel.PropertyChangedEventArgs)
07-16 17:41:19.182 E/mono (27212): at TransMission.Mobile.Helper.NotifyBase.OnPropertyChanged (System.String propertyName
07-16 17:41:19.182 E/mono-rt (27212): [ERROR] FATAL UNHANDLED EXCEPTION: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object
07-16 17:41:19.182 E/mono-rt (27212): at Xamarin.Forms.Forms+AndroidPlatformServices.BeginInvokeOnMainThread (System.Action action) [0x00000] in <filename unknown>:0
07-16 17:41:19.182 E/mono-rt (27212): at Xamarin.Forms.Device.BeginInvokeOnMainThread (System.Action action) [0x00000] in <filename unknown>:0
07-16 17:41:19.182 E/mono-rt (27212): at Xamarin.Forms.BindingExpression+BindingExpressionPart.PropertyChanged (System.Object sender, System.ComponentModel.PropertyChangedEventArgs args) [0x00000] in <filename unknown>:0
07-16 17:41:19.182 E/mono-rt (27212): at (wrapper delegate-invoke) <Module>:invoke_void__this___object_PropertyChangedEventArgs (object,System.ComponentModel.PropertyChangedEventArgs)
07-16 17:41:19.182 E/mono-rt (27212): at (wrapper delegate-invoke) <Module>:invoke_void__this___object_PropertyChangedEventArgs (object,System.ComponentModel.PropertyChangedEventArgs)
07-16 17:41:19.182 E/mono-rt (27212): at TransMission.Mobile.Helper.NotifyBase.OnPropertyChanged (System.String
Das Programm "Mono" wurde mit Code 0 (0x0) beendet.
As my debug output states this seems to happen for a DateTime property that is set to what seems to be a min value for the DatePicker:
07-16 17:32:45.761 I/mono-stdout(27212): DEBUG - Changing value from '01.01.0001 00:00:00' to '01.01.1900 00:00:00'.
07-16 17:32:45.771 I/mono-stdout(27212): DEBUG - Raising PropertyChanged for: 'TransMissionCore.Date'.
My codes works perfectly on iOS. But on Android this is a show stopper.
I tried my app with the latest version of Xamarin.Forms (1.2.1.6229) and with 1.1.1.6206 but this makes no difference.
Is there some kind of workaround? Or am i making a mistake?
Please give advice.
This is fixed in the latest release of xamarin forms.
I did not spend enough attention to the stack trace of the exception in the latest version.
I thought the stack traces are equal but they differ in some parts
This seems to have another source and comes from another part of my app.
Related
I set my main page in this way:
namespace MyNamepage
{
public partial class MyPage: ContentPage
{
private Realm realm;
public MyPage()
{
InitializeComponent();
this.realm = Realm.GetInstance();
}
}
}
Debugging the Android project i got this error and the app crash:
System.Reflection.TargetInvocationException: Exception has been thrown
by the target of an invocation.
I've installed "Realm" in PCL and in Droid Project using NuGet but it seems doesn't work.
If i remove the GetInstance() call, the app doesn't crash;
Stack trace:
10-17 10:36:31.935 I/MonoDroid(31518): UNHANDLED EXCEPTION:
10-17 10:36:31.955 I/MonoDroid(31518): System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.PlatformNotSupportedException: The PCL build of Realm is being linked which probably means you need to use NuGet or otherwise link a platform-specific Realm.dll to your main application.
10-17 10:36:31.955 I/MonoDroid(31518): at Realms.RealmPCLHelpers.ThrowProxyShouldNeverBeUsed () [0x00000] in <filename unknown>:0
10-17 10:36:31.955 I/MonoDroid(31518): at Realms.Realm.GetInstance (Realms.RealmConfiguration config) [0x00000] in <filename unknown>:0
10-17 10:36:31.955 I/MonoDroid(31518): at MyPack.SidePage.MyPage..ctor () [0x00008] in C:\Users\User\documents\visual studio 2015\Projects\MyPack\MyPack\MyPack\SidePage\MyPage.xaml.cs:14
10-17 10:36:31.955 I/MonoDroid(31518): at (wrapper managed-to-native) System.Reflection.MonoCMethod:InternalInvoke (System.Reflection.MonoCMethod,object,object[],System.Exception&)
10-17 10:36:31.955 I/MonoDroid(31518): at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00002] in /Users/builder/data/lanes/3415/7db2aac3/source/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:644
10-17 10:36:31.965 I/MonoDroid(31518): --- End of inner exception stack trace ---
10-17 10:36:31.965 I/MonoDroid(31518): at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00016] in /Users/builder/data/lanes/3415/7db2aac3/source/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:650
10-17 10:36:31.965 I/MonoDroid(31518): at System.RuntimeType.CreateInstanceMono (Boolean nonPublic) [0x000ca] in /Users/builder/data/lanes/3415/7db2aac3/source/mono/mcs/class/corlib/ReferenceSources/RuntimeType.cs:115
10-17 10:36:31.965 I/MonoDroid(31518): at System.RuntimeType.CreateInstanceSlow (Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, System.Threading.StackCrawlMark& stackMark) [0x0001a] in /Users/builder/data/lanes/3415/7db2aac3/source/mono/mcs/class/corlib/ReferenceSources/RuntimeType.cs:89
10-17 10:36:31.965 I/MonoDroid(31518): at System.RuntimeType.CreateInstanceDefaultCtor (Boolean publicOnly, Boolean skipCheckThis, Boolean fillCache, System.Threading.StackCrawlMark& stackMark) [0x0002a] in /Users/builder/data/lanes/3415/7db2aac3/source/mono/external/referencesource/mscorlib/system/rttype.cs:5599
10-17 10:36:31.965 I/MonoDroid(31518): at System.Activator.CreateInstance (System.Type type, Boolean nonPublic) [0x00040] in /Users/builder/data/lanes/3415/7db2aac3/source/mono/external/referencesource/mscorlib/system/activator.cs:201
10-17 10:36:31.965 I/MonoDroid(31518): at System.Activator.CreateInstance (System.Type type) [0x00000] in /Users/builder/data/lanes/3415/7db2aac3/source/mono/external/referencesource/mscorlib/system/activator.cs:134
10-17 10:36:31.965 I/MonoDroid(31518): at MyPack.MainPage.OnItemSelected (System.Object sender, Xamarin.Forms.SelectedItemChangedEventArgs e) [0x00016] in C:\Users\User\documents\visual studio 2015\Projects\MyPack\MyPack\MyPack\MainPage.xaml.cs:24
10-17 10:36:31.965 I/MonoDroid(31518): at (wrapper delegate-invoke) System.EventHandler`1[Xamarin.Forms.SelectedItemChangedEventArgs]:invoke_void_object_TEventArgs (object,Xamarin.Forms.SelectedItemChangedEventArgs)
10-17 10:36:31.975 I/MonoDroid(31518): at Xamarin.Forms.ListView.OnSelectedItemChanged (Xamarin.Forms.BindableObject bindable, System.Object oldValue, System.Object newValue) [0x0001c] in <filename unknown>:0
10-17 10:36:31.975 I/MonoDroid(31518): at Xamarin.Forms.BindableObject.SetValueActual (Xamarin.Forms.BindableProperty property, Xamarin.Forms.BindablePropertyContext context, System.Object value, Boolean currentlyApplying, SetValueFlags attributes, Boolean silent) [0x0010e] in <filename unknown>:0
10-17 10:36:31.975 I/MonoDroid(31518): at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, SetValueFlags attributes, SetValuePrivateFlags privateAttributes) [0x0014b] in <filename unknown>:0
10-17 10:36:31.975 I/MonoDroid(31518): at Xamarin.Forms.BindableObject.SetValueCore (Xamarin.Forms.BindableProperty property, System.Object value, SetValueFlags attributes) [0x00000] in <filename unknown>:0
10-17 10:36:31.975 I/MonoDroid(31518): at Xamarin.Forms.ListView.NotifyRowTapped (Int32 groupIndex, Int32 inGroupIndex, Xamarin.Forms.Cell cell) [0x0004c] in <filename unknown>:0
10-17 10:36:31.975 I/MonoDroid(31518): at Xamarin.Forms.ListView.NotifyRowTapped (Int32 index, Xamarin.Forms.Cell cell) [0x00023] in <filename unknown>:0
10-17 10:36:31.975 I/MonoDroid(31518): at Xamarin.Forms.Platform.Android.ListViewAdapter.HandleItemClick (Android.Widget.AdapterView parent, Android.Views.View view, Int32 position, Int64 id) [0x00056] in <filename unknown>:0
10-17 10:36:31.975 I/MonoDroid(31518): at Xamarin.Forms.Platform.Android.CellAdapter.OnItemClick (Android.Widget.AdapterView parent, Android.Views.View view, Int32 position, Int64 id) [0x0002e] in <filename unknown>:0
10-17 10:36:31.975 I/MonoDroid(31518): at Android.Widget.AdapterView+IOnItemClickListenerInvoker.n_OnItemClick_Landroid_widget_AdapterView_Landroid_view_View_IJ (IntPtr jnienv, IntPtr native__this, IntPtr native_parent, IntPtr native_view, Int32 position, Int64 id) [0x00019] in /Users/builder/data/lanes/3415/7db2aac3/source/monodroid/src/Mono.Android/platforms/android-23/src/generated/Android.Widget.AdapterView.cs:215
10-17 10:36:31.975 I/MonoDroid(31518): at (wrapper dynamic-method) System.Object:585983a8-79f2-48a3-ac33-5b4c905219f1 (intptr,intptr,intptr,intptr,int,long)
10-17 10:36:31.995 D/Mono (31518): DllImport searching in: '__Internal' ('(null)').
10-17 10:36:31.995 D/Mono (31518): Searching for 'java_interop_jnienv_throw'.
10-17 10:36:31.995 D/Mono (31518): Probing 'java_interop_jnienv_throw'.
10-17 10:36:31.995 D/Mono (31518): Found as 'java_interop_jnienv_throw'.
An unhandled exception occured.
10-17 10:36:34.115 E/mono (31518):
10-17 10:36:34.115 E/mono (31518): Unhandled Exception:
10-17 10:36:34.115 E/mono (31518): System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.PlatformNotSupportedException: The PCL build of Realm is being linked which probably means you need to use NuGet or otherwise link a platform-specific Realm.dll to your main application.
10-17 10:36:34.115 E/mono (31518): at Realms.RealmPCLHelpers.ThrowProxyShouldNeverBeUsed () [0x00000] in <filename unknown>:0
10-17 10:36:34.115 E/mono (31518): at Realms.Realm.GetInstance (Realms.RealmConfiguration config) [0x00000] in <filename unknown>:0
10-17 10:36:34.115 E/mono (31518): at MyPack.SidePage.MyPage..ctor () [0x00008] in C:\Users\User\documents\visual studio 2015\Projects\MyPack\MyPack\MyPack\SidePage\MyPage.xaml.cs:14
10-17 10:36:34.115 E/mono (31518): at (wrapper managed-to-native) System.Reflection.MonoCMethod:InternalInvoke (System.Reflection.MonoCMethod,object,object[],System.Exception&)
10-17 10:36:34.115 E/mono (31518): at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00002] in /Users/builder/data/lanes/3415/7db2aac3/source/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:644
10-17 10:36:34.115 E/mono (31518): --- End of inner exception stack trace ---
10-17 10:36:34.115 E/mono (31518): at (wrapper dynamic-method) System.Object:585983a8-79f2-48a3-ac33-5b4c905219f1 (intptr,intptr,intptr,intptr,int,long)
10-17 10:36:34.115 E/mono (31518): at (wrapper native-to-managed) System.Object:585983a8-79f2-48a3-ac33-5b4c905219f1 (intptr,intptr,intptr,intptr,int,long)
10-17 10:36:34.115 E/mono-rt (31518): [ERROR] FATAL UNHANDLED EXCEPTION: System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.PlatformNotSupportedException: The PCL build of Realm is being linked which probably means you need to use NuGet or otherwise link a platform-specific Realm.dll to your main application.
10-17 10:36:34.115 E/mono-rt (31518): at Realms.RealmPCLHelpers.ThrowProxyShouldNeverBeUsed () [0x00000] in <filename unknown>:0
10-17 10:36:34.115 E/mono-rt (31518): at Realms.Realm.GetInstance (Realms.RealmConfiguration config) [0x00000] in <filename unknown>:0
10-17 10:36:34.115 E/mono-rt (31518): at MyPack.SidePage.MyPage..ctor () [0x00008] in C:\Users\User\documents\visual studio 2015\Projects\MyPack\MyPack\MyPack\SidePage\MyPage.xaml.cs:14
10-17 10:36:34.115 E/mono-rt (31518): at (wrapper managed-to-native) System.Reflection.MonoCMethod:InternalInvoke (System.Reflection.MonoCMethod,object,object[],System.Exception&)
10-17 10:36:34.115 E/mono-rt (31518): at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters) [0x00002] in /Users/builder/data/lanes/3415/7db2aac3/source/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:644
10-17 10:36:34.115 E/mono-rt (31518): --- End of inner exception stack trace ---
10-17 10:36:34.115 E/mono-rt (31518): at (wrapper dynamic-method) System.Object:585983a8-79f2-48a3-ac33-5b4c905219f1 (intptr,intptr,intptr,intptr,int,long)
10-17 10:36:34.115 E/mono-rt (31518): at (wrapper native-to-managed) System.Object:585983a8-79f2-48a3-ac33-5b4c905219f1 (intptr,intptr,intptr,intptr,int,long)
In mgmain JNI_OnLoad
As the stack trace indicates and the path you have posted in the comments shows. You have installed the PCL version into the platform specific projects. Which is why it throws the PlatformNotSupportedException exception you are getting.
Try reinstalling the NuGet in your platform specific projects. Alternatively you can manually change the reference to point at:
packages\Realm.0.78.1\lib\MonoAndroid44\Realm.dll
You shouldn't have any reference to the portable folder in your platform specific project.
I had a similar problem using Xamarin.Forms 3.4.0.1008975 with Realm 4.0.1
Unhandled Exception: System.TypeInitializationException: The type
initializer for 'Realms.SharedRealmHandle' threw an exception.
occurred
The solution was to completely uninstall the nuget Realm package from all projects in the solution and reinstall Realm back again. Also make sure that you have the FodyWeaver.xml file in all projects.
When i try to start the server i got everytime the same error.
i searched here for a solution and found something that i have to edit my connection string. After this im get the same error again
Sorry for my bad english
`RRChatServer.exe
Unhandled Exception: System.EntryPointNotFoundException:
CreateSemaphore at (wrapper managed-to-native)
MySql.Data.Common.Semaphore:CreateSemaphore
(MySql.Data.Common.SECURITY_ATTRIBUTES&,int,int,string) at
MySql.Data.Common.Semaphore..ctor (Int32 initialCount, Int32
maximumCount) [0x00000] in :0 at (wrapper
remoting-invoke-with-check) MySql.Data.Common.Semaphore:.ctor
(int,int) at MySql.Data.MySqlClient.MySqlPool..ctor
(MySql.Data.MySqlClient.MySqlConnectionString settings) [0x00000] in
:0 at
MySql.Data.MySqlClient.MySqlPoolManager.GetPool
(MySql.Data.MySqlClient.MySqlConnectionString settings) [0x00000] in
:0 at MySql.Data.MySqlClient.MySqlConnection.Open
() [0x00000] in :0 [ERROR] FATAL UNHANDLED
EXCEPTION: System.EntryPointNotFoundException: CreateSemaphore at
(wrapper managed-to-native)
MySql.Data.Common.Semaphore:CreateSemaphore
(MySql.Data.Common.SECURITY_ATTRIBUTES&,int,int,string) at
MySql.Data.Common.Semaphore..ctor (Int32 initialCount, Int32
maximumCount) [0x00000] in :0 at (wrapper
remoting-invoke-with-check) MySql.Data.Common.Semaphore:.ctor
(int,int) at MySql.Data.MySqlClient.MySqlPool..ctor
(MySql.Data.MySqlClient.MySqlConnectionString settings) [0x00000] in
:0 at
MySql.Data.MySqlClient.MySqlPoolManager.GetPool
(MySql.Data.MySqlClient.MySqlConnectionString settings) [0x00000] in
:0 at MySql.Data.MySqlClient.MySqlConnection.Open
() [0x00000] in :0`
I've installed mono on my 64-bit Windows 7 using:
mono-3.2.3-gtksharp-2.12.11-win32-0.exe
from go-mono download page
in directory (without spaces in path) changed according to Jim Gomes' advice
Successfully run first two examples
Console Hello World
Gtk# Hello World
from Mono Basics article.
But the 3d example "WinForms Hello World" is compiled without errors and run from Windows (by double-clicking in Windows Explorer) successfully but running:
mono hello.exe
from "Mono-3.2.3 Command Prompt" window produces the errors listed below
(note that first two examples including a window of second example was launched successfully from command prompt invoking through mono ...)
What is the problem and how to overcome it?
UPDATE
According to mentioned article "Mono Basics" I compiled the 3d example "Winforms Hello World" with gmcs hello.cs -pkg:dotnet.
BTW, where is that dotnet package located?
Is it in directory with the same name? I do not have a single dir with exactly such name dotnet under Mono-3.2.3 dir
The errors produced by running mono hello.exe from "Mono-3.2.3 Command Prompt"
Unhandled Exception:
System.TypeInitializationException:
An exception was thrown by the type initializer for
System.Windows.Forms.WindowsFormsSynchronizationContext
---> System.TypeInitializationException:
An exception was thrown by the type initializer for
System.Windows.Forms.ThemeEngine ---> System.TypeInitializationException:
An exception was thrown by the type initializer for
System.Windows.Forms.ThemeWin32Classic
---> System.TypeInitializationException:
An exception was thrown by the type initializer for System.Drawing.KnownColors
---> System.TypeInitializationException:
An exception was thrown by the type initializer for System.Drawing.GDIPlus
---> System.DllNotFoundException: /tmp/install/lib/libgdiplus.so at
(wrapper managed-to-native) System.Drawing.GDIPlus:GdiplusStartup
(ulong&,System.Drawing.GdiplusStartupInput&,System.Drawing.GdiplusStartupOutput&)
at System.Drawing.GDIPlus..cctor () [0x00000] in <filename unknown>:0
--- End of inner exception stack trace ---
at System.Drawing.KnownColors..cctor () [0x00000] in <filename unknown>:0
--- End of inner exception stack trace ---
at System.Drawing.Color.get_Black () [0x00000] in <filename unknown>:0
at System.Windows.Forms.ThemeWin32Classic..cctor () [0x00000] in <filename unk
nown>:0
--- End of inner exception stack trace ---
at System.Windows.Forms.ThemeEngine..cctor () [0x00000] in <filename unknown>:
0
--- End of inner exception stack trace ---
at System.Windows.Forms.SystemInformation.get_MenuAccessKeysUnderlined () [0x0
0000] in <filename unknown>:0
at System.Windows.Forms.Control..ctor () [0x00000] in <filename unknown>:0
at (wrapper remoting-invoke-with-check) System.Windows.Forms.Control:.ctor ()
at System.Windows.Forms.WindowsFormsSynchronizationContext..cctor () [0x00000]
in <filename unknown>:0
--- End of inner exception stack trace ---
at System.Windows.Forms.Control..ctor () [0x00000] in <filename unknown>:0
at System.Windows.Forms.ScrollableControl..ctor () [0x00000] in <filename unkn own>:0
at System.Windows.Forms.ContainerControl..ctor () [0x00000] in <filename unkno wn>:0
at System.Windows.Forms.Form..ctor () [0x00000] in <filename unknown>:0
at HelloWorld..ctor () [0x00000] in <filename unknown>:0
at (wrapper remoting-invoke-with-check) HelloWorld:.ctor ()
at HelloWorld.Main () [0x00000] in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeInitializationException:
An exception was thrown by the type initializer for
System.Windows.Forms.WindowsFormsSynchronizationContext
---> System.TypeInitializationException:
An exception was thrown by the type initializer for
System.Windows.Forms.ThemeEngine
---> System.TypeInitializationException:
An exception was thrown by the type initializer for
System.Windows.Forms.ThemeWin32Classic
---> System.TypeInitializationException:
An exception was thrown by the type initializer for
System.Drawing.KnownColors
---> System.TypeInitializationException:
An exception was thrown by the type initializer for
System.Drawing.GDIPlus
---> System.DllNotFoundException: /tmp/install/lib/libgdiplus.so
at (wrapper managed-to-native) System.Drawing.GDIPlus:GdiplusStartup (ulong&,System.Drawing.GdiplusStartupInput&,System.Drawing.GdiplusStartupOutput&)
at System.Drawing.GDIPlus..cctor () [0x00000] in <filename unknown>:0
--- End of inner exception stack trace ---
at System.Drawing.KnownColors..cctor () [0x00000] in <filename unknown>:0
--- End of inner exception stack trace ---
at System.Drawing.Color.get_Black () [0x00000] in <filename unknown>:0
at System.Windows.Forms.ThemeWin32Classic..cctor () [0x00000] in <filename unk
nown>:0
--- End of inner exception stack trace ---
at System.Windows.Forms.ThemeEngine..cctor () [0x00000] in <filename unknown>:
0
--- End of inner exception stack trace ---
at System.Windows.Forms.SystemInformation.get_MenuAccessKeysUnderlined () [0x0
0000] in <filename unknown>:0
at System.Windows.Forms.Control..ctor () [0x00000] in <filename unknown>:0
at (wrapper remoting-invoke-with-check) System.Windows.Forms.Control:.ctor ()
at System.Windows.Forms.WindowsFormsSynchronizationContext..cctor () [0x00000]
in <filename unknown>:0
--- End of inner exception stack trace ---
at System.Windows.Forms.Control..ctor () [0x00000] in <filename unknown>:0
at System.Windows.Forms.ScrollableControl..ctor () [0x00000] in <filename unkn
own>:0
at System.Windows.Forms.ContainerControl..ctor () [0x00000] in <filename unkno
wn>:0
at System.Windows.Forms.Form..ctor () [0x00000] in <filename unknown>:0
at HelloWorld..ctor () [0x00000] in <filename unknown>:0
at (wrapper remoting-invoke-with-check) HelloWorld:.ctor ()
at HelloWorld.Main () [0x00000] in <filename unknown>:0
I have encountered this problem.
I think this is mono's bug.
If you installed mono in C:\Program Files (x86)\Mono-3.2.3\etc\mono
Find the file C:\Program Files (x86)\Mono-3.2.3\etc\mono\config
Change Line 29-30:
<dllmap dll="gdiplus" target="/tmp/install/lib/libgdiplus.so" />
<dllmap dll="gdiplus.dll" target="/tmp/install/lib/libgdiplus.so" />
To:
<dllmap dll="gdiplus" target="/tmp/install/lib/libgdiplus.so" os="!windows" />
<dllmap dll="gdiplus.dll" target="/tmp/install/lib/libgdiplus.so" os="!windows" />
And this problem will be solved.
As per this answer regarding failed mono-test-install results, I put the following in test.cs:
using System;
using System.Drawing;
class X {
static void Main ()
{
Bitmap b = new Bitmap (100, 100);
}
}
Then ran
mcs -pkg:dotnet test.cs
output:
test.cs(7,16): warning CS0219: The variable `b' is assigned but its
value is never used Compilation succeeded - 1 warning(s)
And ran the resulting exe with:
mono test.exe
output:
Unhandled Exception:
System.TypeInitializationException: An exception was thrown by the type initializer for System.Drawing.GDIPlus ---> System.DllNotFoundException: /usr/local/lib/libgdiplus.so
at (wrapper managed-to-native) System.Drawing.GDIPlus:GdiplusStartup (ulong&,System.Drawing.GdiplusStartupInput&,System.Drawing.GdiplusStartupOutput&)
at System.Drawing.GDIPlus..cctor () [0x00000] in <filename unknown>:0
--- End of inner exception stack trace ---
at System.Drawing.Bitmap..ctor (Int32 width, Int32 height, PixelFormat format) [0x00000] in <filename unknown>:0
at System.Drawing.Bitmap..ctor (Int32 width, Int32 height) [0x00000] in <filename unknown>:0
at (wrapper remoting-invoke-with-check) System.Drawing.Bitmap:.ctor (int,int)
at X.Main () [0x00000] in <filename unknown>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeInitializationException: An exception was thrown by the type initializer for System.Drawing.GDIPlus ---> System.DllNotFoundException: /usr/local/lib/libgdiplus.so
at (wrapper managed-to-native) System.Drawing.GDIPlus:GdiplusStartup (ulong&,System.Drawing.GdiplusStartupInput&,System.Drawing.GdiplusStartupOutput&)
at System.Drawing.GDIPlus..cctor () [0x00000] in <filename unknown>:0
--- End of inner exception stack trace ---
at System.Drawing.Bitmap..ctor (Int32 width, Int32 height, PixelFormat format) [0x00000] in <filename unknown>:0
at System.Drawing.Bitmap..ctor (Int32 width, Int32 height) [0x00000] in <filename unknown>:0
at (wrapper remoting-invoke-with-check) System.Drawing.Bitmap:.ctor (int,int)
at X.Main () [0x00000] in <filename unknown>:0
Is it safe to ignore this or should I be debugging the line NotFoundException: /usr/local/lib/libgdiplus.so next?
Thanks Jon, I'd just found that page and though I didn't follow it verbatim, I put a symlink in as:
sudo ln -s /usr/lib/libgdiplus.so /usr/local/lib/libgdiplus.so
Which resolved the errors and now mono-test-install returns:
Your have a working System.Drawing setup
Besides the grammatical issues, it should be resolved.
The following post looks similar to my issue, but ultimately it doesn't look exactly the same down to all the details, so I am calling that out to prevent claims that its the same.
I am following this monogame tutorial (currently on step 2) in Xamarin Studio:
When I run the resulting monogame app at the end of step 2 I get the following exception (pasted at the end) when I hit the line of code that attempts to load the player content. I have the player content file setup correctly AFAIK, its copied to the output folder, but I am assuming that its somehow not deployed correctly to the Andriod Virtual Machine (AVM), which I have not been able to figure out how to examine the deployed contents. I pulled up Android Monitor to explore the AVM and try to figure out where things are, but I haven't had any luck figuring that out... The file not found exception seems to be clear that what's running on the AVM isn't finding the content file... but I can't figure out how to correct that.
Any help would be appreciated, thanks!
The sources and project that I am having this issue with are here
The exception I am seeing is the following:
[MonoDroid] UNHANDLED EXCEPTION: Microsoft.Xna.Framework.Content.ContentLoadException: Could not load Graphics\player asset as a non-content file! ---> Microsoft.Xna.Framework.Content.ContentLoadException: Opening stream error. ---> Java.IO.FileNotFoundException: Exception of type 'Java.IO.FileNotFoundException' was thrown. [MonoDroid] at Android.Runtime.JNIEnv.CallObjectMethod (IntPtr jobject, IntPtr jmethod, Android.Runtime.JValue[] parms) [0x00000] in :0 [MonoDroid] at Android.Content.Res.AssetManager.Open (System.String fileName) [0x00000] in :0 [MonoDroid] at Microsoft.Xna.Framework.TitleContainer.OpenStream (System.String name) [0x00000] in :0 [MonoDroid] at Microsoft.Xna.Framework.Content.ContentManager.OpenStream (System.String assetName) [0x00000] in :0 [MonoDroid] --- End of managed exception stack trace --- [MonoDroid] java.io.FileNotFoundException: Content/Graphics/player.xnb [MonoDroid] at android.content.res.AssetManager.openAsset(Native Method) [MonoDroid] at android.content.res.AssetManager.open(AssetManager.java:315) [MonoDroid] at android.content.res.AssetManager.open(AssetManager.java:289) [MonoDroid] at mono.java.lang.RunnableImplementor.n_run(Native Method) [MonoDroid] at mono.java.lang.RunnableImplementor.run(RunnableImplementor.java:29) [MonoDroid] at android.os.Handler.handleCallback(Handler.java:605) [MonoDroid] at android.os.Handler.dispatchMessage(Handler.java:92) [MonoDroid] at android.os.Looper.loop(Looper.java:137) [MonoDroid] at android.app.ActivityThread.main(ActivityThread.java:4424) [MonoDroid] at java.lang.reflect.Method.invokeNative(Native Method) [MonoDroid] at java.lang.reflect.Method.invoke(Method.java:511) [MonoDroid] at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784) [MonoDroid] at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) [MonoDroid] at dalvik.system.NativeStart.main(Native Method) [MonoDroid] [MonoDroid] --- End of inner exception stack trace --- [MonoDroid] at Microsoft.Xna.Framework.Content.ContentManager.OpenStream (System.String assetName) [0x00000] in :0 [MonoDroid] at Microsoft.Xna.Framework.Content.ContentManager.ReadAsset[Texture2D] (System.String assetName, System.Action1 recordDisposableObject) [0x00000] in :0
[MonoDroid] --- End of inner exception stack trace ---
[MonoDroid] at Microsoft.Xna.Framework.Content.ContentManager.ReadAsset (string,System.Action1) <0x0042c> [MonoDroid] at Microsoft.Xna.Framework.Content.ContentManager.Load (string) <0x000c3> [MonoDroid] at SampleShooter.Game1.LoadContent () <0x0018b> [MonoDroid] at Microsoft.Xna.Framework.Game.Initialize () <0x0023f> [MonoDroid] at SampleShooter.Game1.Initialize () <0x00037> [MonoDroid] at Microsoft.Xna.Framework.Game.DoInitialize () <0x00037> [MonoDroid] at Microsoft.Xna.Framework.AndroidGamePlatform.BeforeUpdate (Microsoft.Xna.Framework.GameTime) <0x0002b> [MonoDroid] at Microsoft.Xna.Framework.Game.DoUpdate (Microsoft.Xna.Framework.GameTime) <0x0002f> [MonoDroid] at Microsoft.Xna.Framework.Game.Tick () <0x00493> [MonoDroid] at Microsoft.Xna.Framework.AndroidGameWindow.OnUpdateFrame (OpenTK.FrameEventArgs) <0x000a7> [MonoDroid] at OpenTK.Platform.Android.AndroidGameView.UpdateFrameInternal (OpenTK.FrameEventArgs) <0x00033> [MonoDroid] at OpenTK.Platform.Android.AndroidGameView.RunIteration (System.Threading.CancellationToken) <0x001c3> [MonoDroid] at OpenTK.Platform.Android.AndroidGameView/c__AnonStorey0.<>m__2 (object) <0x00027> [MonoDroid] at Android.App.SyncContext/c__AnonStorey2F.<>m__1A () <0x00023> [MonoDroid] at Java.Lang.Thread/RunnableImplementor.Run () <0x0003f> [MonoDroid] at Java.Lang.IRunnableInvoker.n_Run (intptr,intptr) <0x00037> [MonoDroid] at (wrapper dynamic-method) object.e85befee-f4e0-4f15-9232-77621081c7b5 (intptr,intptr) <0x0003b> [mono] [mono] Unhandled Exception: [mono] Microsoft.Xna.Framework.Content.ContentLoadException: Could not load Graphics\player asset as a non-content file! ---> Microsoft.Xna.Framework.Content.ContentLoadException: Opening stream error. ---> Java.IO.FileNotFoundException: Exception of type 'Java.IO.FileNotFoundException' was thrown. [mono] at Android.Runtime.JNIEnv.CallObjectMethod (IntPtr jobject, IntPtr jmethod, Android.Runtime.JValue[] parms) [0x00000] in :0 [mono] at Android.Content.Res.AssetManager.Open (System.String fileName) [0x00000] in :0 [mono] at Microsoft.Xna.Framework.TitleContainer.OpenStream (System.String name) [0x00000] in :0 [mono] at Microsoft.Xna.Framework.Content.ContentManager.OpenStream (System.String assetName) [0x00000] in :0 [mono] --- End of managed exception stack trace --- [mono] java.io.FileNotFoundException: Content/Graphics/player.xnb [mono] at android.content.res.AssetManager.openAsset(Native Method) [mono] at android.content.res.AssetManager.open(AssetManager.ja [mono] [ERROR] FATAL UNHANDLED EXCEPTION: Microsoft.Xna.Framework.Content.ContentLoadException: Could not load Graphics\player asset as a non-content file! ---> Microsoft.Xna.Framework.Content.ContentLoadException: Opening stream error. ---> Java.IO.FileNotFoundException: Exception of type 'Java.IO.FileNotFoundException' was thrown. [mono] at Android.Runtime.JNIEnv.CallObjectMethod (IntPtr jobject, IntPtr jmethod, Android.Runtime.JValue[] parms) [0x00000] in :0 [mono] at Android.Content.Res.AssetManager.Open (System.String fileName) [0x00000] in :0 [mono] at Microsoft.Xna.Framework.TitleContainer.OpenStream (System.String name) [0x00000] in :0 [mono] at Microsoft.Xna.Framework.Content.ContentManager.OpenStream (System.String assetName) [0x00000] in :0 [mono] --- End of managed exception stack trace --- [mono] java.io.FileNotFoundException: Content/Graphics/player.xnb [mono] at android.content.res.AssetManager.openAsset(Native Method) [mono] at android.content.res.AssetManager.open(As
So I finally figured out that I needed to mark the XNB file as an AndroidAsset for the build action, and not Content as the example stated. Since the example I am following is aimed at Windows Mobile development this makes sense since the file would normally be marked as content for a Windows application, whereas for Android these files need to be marked as AndriodAsset in order for XNA to be able to access the raw content data, regardless of if the file is in a content or asset folder. The content manager's root folder by default is "Content", so you need to add the file there and mark it as an asset, not content...
Content for an android monogame project should be added to the project in the Assets/Content folder as built .xnb files rather than just copied to the output directory