Why does the below code fail at runtime?
MongoCollection<BsonDocument> tempCollection = DBHelper.GetInstance().TempCollection();
IList<BsonDocument> documents = (from d in tempCollection.AsQueryable()
where d["Form"].AsString == id
select d).ToList();
while this works just fine?
MongoCollection<BsonDocument> tempCollection = DBHelper.GetInstance().TempCollection();
IList<BsonDocument> documents = (from d in tempCollection.FindAll()
where d["Form"].AsString == id
select d).ToList();
"id" is a parameter of type string to my function where this code is.
I get the below runtime error:
System.FormatException
Input string was not in the correct format
Description: HTTP 500.Error processing request.
Details: Non-web exception. Exception origin (name of application or object): mscorlib.
Exception stack trace:
at int.Parse (string,System.Globalization.NumberStyles,System.IFormatProvider) [0x00012] in /home/karim/.yaourt/yaourt-tmp-karim/aur-mono-git/src/mono/mcs/class/corlib
/System/Int32.cs:639 at int.Parse (string,System.IFormatProvider) [0x00000] in /home/karim/.yaourt/yaourt-tmp-karim/aur-mono-git/src/mono/mcs/class/corlib/System/Int32.cs:205 at System.Convert.ToInt32 (string,System.IFormatProvider) [0x00008] in /home/karim/.yaourt/yaourt-tmp-karim/aur-mono-git/src/mono/mcs/class/corlib/System/Convert.cs:1135 at string.System.IConvertible.ToInt32 (System.IFormatProvider) [0x00000] in /home/karim/.yaourt/yaourt-tmp-karim/aur-mono-git/src/mono/mcs/class/corlib/System/String.cs:2482 at System.Convert.ToInt32 (object,System.IFormatProvider) [0x00008] in /home/karim/.yaourt/yaourt-tmp-karim/aur-mono-git/src/mono/mcs/class/corlib/System/Convert.cs:1173 at System.Convert.ToInt32 (object) [0x00008] in /home/karim/.yaourt/yaourt-tmp-karim/aur-mono-git/src/mono/mcs/class/corlib/System/Convert.cs:1166 at MongoDB.Driver.Linq.Utils.BsonSerializationInfoFinder.VisitGetItem (System.Linq.Expressions.MethodCallExpression) <IL 0x00028, 0x001ab> at MongoDB.Driver.Linq.Utils.BsonSerializationInfoFinder.VisitMethodCall (System.Linq.Expressions.MethodCallExpression) <IL 0x00035, 0x00133> at MongoDB.Driver.Linq.ExpressionVisitor`1<MongoDB.Bson.Serialization.BsonSerializationInfo>.Visit (System.Linq.Expressions.Expression) <0x004e8> at MongoDB.Driver.Linq.Utils.BsonSerializationInfoFinder.Visit (System.Linq.Expressions.Expression) <IL 0x00014, 0x000af> at MongoDB.Driver.Linq.Utils.BsonSerializationInfoFinder.VisitMember (System.Linq.Expressions.MemberExpression) <IL 0x00007, 0x0008c> at MongoDB.Driver.Linq.ExpressionVisitor`1<MongoDB.Bson.Serialization.BsonSerializationInfo>.Visit (System.Linq.Expressions.Expression) <0x00467> at MongoDB.Driver.Linq.Utils.BsonSerializationInfoFinder.Visit (System.Linq.Expressions.Expression) <IL 0x00014, 0x000af> at MongoDB.Driver.Linq.Utils.BsonSerializationInfoFinder.GetSerializationInfo (System.Linq.Expressions.Expression,System.Collections.Generic.Dictionary`2<System.Linq.Expressions.Expression, MongoDB.Bson.Serialization.BsonSerializationInfo>) <IL 0x00009, 0x0009e> at MongoDB.Driver.Linq.Utils.BsonSerializationInfoHelper.GetSerializationInfo (System.Linq.Expressions.Expression) <IL 0x0000e, 0x0006f> at MongoDB.Driver.Linq.PredicateTranslator.BuildComparisonQuery (System.Linq.Expressions.Expression,System.Linq.Expressions.ExpressionType,System.Linq.Expressions.ConstantExpression) <IL 0x00140, 0x005d7> at MongoDB.Driver.Linq.PredicateTranslator.BuildComparisonQuery (System.Linq.Expressions.BinaryExpression) <IL 0x0008c, 0x003f7> at MongoDB.Driver.Linq.PredicateTranslator.BuildQuery (System.Linq.Expressions.Expression) <IL 0x000e6, 0x003eb> at MongoDB.Driver.Linq.SelectQuery.BuildQuery () <IL 0x00024, 0x000f3> at MongoDB.Driver.Linq.SelectQuery.Execute () <IL 0x0005c, 0x002bb> at MongoDB.Driver.Linq.MongoQueryProvider.Execute (System.Linq.Expressions.Expression) <IL 0x00017, 0x000b8> at MongoDB.Driver.Linq.MongoQueryable`1<MongoDB.Bson.BsonDocument>.GetEnumerator () <0x0004b> at System.Collections.Generic.List`1<MongoDB.Bson.BsonDocument>.AddEnumerable (System.Collections.Generic.IEnumerable`1<MongoDB.Bson.BsonDocument>) <0x00067> at System.Collections.Generic.List`1<MongoDB.Bson.BsonDocument>..ctor (System.Collections.Generic.IEnumerable`1<MongoDB.Bson.BsonDocument>) <0x0015f> at System.Linq.Enumerable.ToList<MongoDB.Bson.BsonDocument> (System.Collections.Generic.IEnumerable`1<MongoDB.Bson.BsonDocument>) <0x00077> at BusinessFlowManager.Controllers.FormController.Preview (string) [0x0012b] in /home/karim/MonoDevelopProjects/BusinessFlowManager/BusinessFlowManager/Controllers/SetupControllers/FormController.cs:139 at (wrapper dynamic-method) object.lambda_method (System.Runtime.CompilerServices.Closure,System.Web.Mvc.ControllerBase,object[]) <IL 0x0000e, 0x000b6> at System.Web.Mvc.ActionMethodDispatcher.Execute (System.Web.Mvc.ControllerBase,object[]) <IL 0x00008, 0x00054> at System.Web.Mvc.ReflectedActionDescriptor.Execute (System.Web.Mvc.ControllerContext,System.Collections.Generic.IDictionary`2<string, object>) <IL 0x0007a, 0x003af> at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod (System.Web.Mvc.ControllerContext,System.Web.Mvc.ActionDescriptor,System.Collections.Generic.IDictionary`2<string, object>) <IL 0x00003, 0x00067> at System.Web.Mvc.ControllerActionInvoker/<>c__DisplayClass15.<InvokeActionMethodWithFilters>b__12 () <IL 0x0002d, 0x000d0> at System.Web.Mvc.ControllerActionInvoker.InvokeActionMethodFilter (System.Web.Mvc.IActionFilter,System.Web.Mvc.ActionExecutingContext,System.Func`1<System.Web.Mvc.ActionExecutedContext>) <IL 0x00031, 0x001ca>
Any explanation or assistance is appreciated.
Thanks
EDIT:
I've modified the code to use Find method along with a MongoQuery instead of using the AsQueryable extension. Essentially takes care of things.
MongoCollection<BsonDocument> tempCollection = DBHelper.GetInstance().TempCollection();
IList<BsonDocument> documents = tempCollection.Find(Query.EQ("Form",id)).ToList();
Related
I have a physical device connected. When the phone is locked and I deploy the application after unlocking, the application works and everything is fine. But if the screen is unlocked and I deploy I get the following error. In this case, everything is ok on the emulator. Help me understand this nonsense.
**System.NullReferenceException:** 'Object reference not set to an instance of an object.'
[HotReload] (2021-03-17 23:08:35.2): INFO: Инициализация горячей перезагрузки XAML…
[HotReload] (2021-03-17 23:08:35.2): WARN: (DriverHelper v 2.0.Android) Unknown Breakpoint Hit: Android.Runtime.JNIEnv.RegisterJniNatives( typeName_ptr, int typeName_len, jniClass, methods_ptr, int methods_len)
"<unnamed thread>" at <unknown> <0xffffffff>
at (wrapper managed-to-native) System.Diagnostics.Debugger.Mono_UnhandledException_internal (System.Exception) <0x00007>
at System.Diagnostics.Debugger.Mono_UnhandledException (System.Exception) [0x00000] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/corlib/System.Diagnostics/Debugger.cs:125
at (wrapper dynamic-method) Android.Runtime.DynamicMethodNameCounter.46 (intptr,intptr) [0x00020] in <44e54a86dea24313a2bdb807df77c27a>:0
at (wrapper native-to-managed) Android.Runtime.DynamicMethodNameCounter.46 (intptr,intptr) [0x00033] in <44e54a86dea24313a2bdb807df77c27a>:0
"ProtocolHandler.SendThread" at <unknown> <0xffffffff>
at (wrapper managed-to-native) System.Threading.Monitor.Monitor_wait (object,int) <0x00007>
at System.Threading.Monitor.ObjWait (bool,int,object) [0x0002f] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/corlib/System.Threading/Monitor.cs:85
at System.Threading.Monitor.Wait (object,int,bool) [0x0000e] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/referencesource/mscorlib/system/threading/monitor.cs:218
at System.Threading.Monitor.Wait (object) [0x00000] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/referencesource/mscorlib/system/threading/monitor.cs:238
at Microsoft.VisualStudio.DesignTools.TapContract.Networking.ProtocolHandler/WaitableActionsList.WaitForData () [0x00019] in <c37c1589af144356b99fb170c5e22242>:0
at Microsoft.VisualStudio.DesignTools.TapContract.Networking.ProtocolHandler.ActionThread (object) [0x00045] in <c37c1589af
144356b99fb170c5e22242>:0
at System.Threading.ThreadHelper.ThreadStart_Context (object) [0x00025] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/referencesource/mscorlib/system/threading/thread.cs:78
at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext,System.Threading.ContextCallback,object,bool) [0x00071] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/referencesource/mscorlib/system/threading/executioncontext.cs:968
at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext,System.Threading.ContextCallback,object,bool) [0x00000] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/referencesource/mscorlib/system/threading/executioncontext.cs:910
at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext,System.Threading.ContextCallback,object) [0x0002b] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/
03-17 23:08:49.317 E/mono (27416): Full thread dump:referencesource/mscorlib/system/threading/executioncontext.cs:899
at System.Threading.ThreadHelper.ThreadStart (object) [0x0000f] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/referencesource/mscorlib/system/threading/thread.cs:93
at (wrapper runtime-invoke) <Module>.runtime_invoke_void__this___object (object,intptr,intptr,intptr) [0x0006b] in <c72658f647bc485bbfb8c9fcaa790862>:0
"<threadpool thread>"
"Debugger agent"
"Thread Pool Worker"
"Thread Pool Worker"
"Thread Pool Worker"
"Timer-Scheduler"
"Finalizer"
"ProtocolHandler.ProcessThread" at <unknown> <0xffffffff>
at (wrapper managed-to-native) System.Threading.Monitor.Monitor_wait (object,int) <0x00007>
at System.Threading.Monitor.ObjWait (bool,int,object) [0x0002f] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/corlib/System.Threading/Monitor.cs:85
at System.Threading.Monitor.Wait (object,int,bool) [0x0000e] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android
/release/mcs/class/referencesource/mscorlib/system/threading/monitor.cs:218
at System.Threading.Monitor.Wait (object) [0x00000] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/referencesource/mscorlib/system/threading/monitor.cs:238
at Microsoft.VisualStudio.DesignTools.TapContract.Networking.ProtocolHandler/WaitableActionsList.WaitForData () [0x00019] in <c37c1589af144356b99fb170c5e22242>:0
at Microsoft.VisualStudio.DesignTools.TapContract.Networking.ProtocolHandler.ActionThread (object) [0x00045] in <c37c1589af144356b99fb170c5e22242>:0
at System.Threading.ThreadHelper.ThreadStart_Context (object) [0x00025] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/referencesource/mscorlib/system/threading/thread.cs:78
at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext,System.Threading.ContextCallback,object,bool) [0x00071] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/re
ferencesource/mscorlib/system/threading/executioncontext.cs:968
at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext,System.Threading.ContextCallback,object,bool) [0x00000] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/referencesource/mscorlib/system/threading/executioncontext.cs:910
at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext,System.Threading.ContextCallback,object) [0x0002b] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/referencesource/mscorlib/system/threading/executioncontext.cs:899
at System.Threading.ThreadHelper.ThreadStart (object) [0x0000f] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/referencesource/mscorlib/system/threading/thread.cs:93
at (wrapper runtime-invoke) <Module>.runtime_invoke_void__this___object (object,intptr,intptr,intptr) [0x0006b] in <c72658f647bc485bbfb8c9fcaa790862>:0
"ProtocolHandler.ReadThread" at <unknow
n> <0xffffffff>
at (wrapper managed-to-native) System.Threading.Monitor.Monitor_wait (object,int) <0x00007>
at System.Threading.Monitor.ObjWait (bool,int,object) [0x0002f] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/corlib/System.Threading/Monitor.cs:85
at System.Threading.Monitor.Wait (object,int,bool) [0x0000e] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/referencesource/mscorlib/system/threading/monitor.cs:218
at System.Threading.Monitor.Wait (object) [0x00000] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/referencesource/mscorlib/system/threading/monitor.cs:238
at Xamarin.HotReload.HotReloadAgent.Microsoft.VisualStudio.DesignTools.TapContract.Networking.IDataBridge.ReadMessage () [0x0002f] in D:\a\1\s\Source\Xamarin.HotReload.Agent\HotReloadAgent.cs:341
at Microsoft.VisualStudio.DesignTools.TapContract.Networking.ProtocolHandler.ReadThread () [0x00038] in <c37c1589af144356b99fb170c
5e22242>:0
at System.Threading.ThreadHelper.ThreadStart_Context (object) [0x00014] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/referencesource/mscorlib/system/threading/thread.cs:74
at System.Threading.ExecutionContext.RunInternal (System.Threading.ExecutionContext,System.Threading.ContextCallback,object,bool) [0x00071] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/referencesource/mscorlib/system/threading/executioncontext.cs:968
at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext,System.Threading.ContextCallback,object,bool) [0x00000] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/referencesource/mscorlib/system/threading/executioncontext.cs:910
at System.Threading.ExecutionContext.Run (System.Threading.ExecutionContext,System.Threading.ContextCallback,object) [0x0002b] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/referencesource
/mscorlib/system/threading/executioncontext.cs:899
at System.Threading.ThreadHelper.ThreadStart () [0x00008] in /Users/builder/jenkins/workspace/archive-mono/2020-02/android/release/mcs/class/referencesource/mscorlib/system/threading/thread.cs:111
at (wrapper runtime-invoke) object.runtime_invoke_void__this__ (object,intptr,intptr,intptr) [0x00067] in <c72658f647bc485bbfb8c9fcaa790862>:0
I have an error with my C# code and MySQL.
Can you help me solve it please ?
Here is my code :
try
{
using (MySqlConnection dbcon = new MySqlConnection(SQLConnectionString))
{
dbcon.Open(); // ERROR HERE
string sql = "SELECT * FROM scp_patreons";
MySqlCommand command = new MySqlCommand();
command = dbcon.CreateCommand();
command.CommandText = sql;
using (MySqlDataReader dr = command.ExecuteReader())
{
while (dr.Read())
{
string fullname = (string)dr["fullname"];
plugin.Info("Name: " + fullname + "");
}
}
}
}
catch (Exception ex)
{
plugin.Info("SQL_ERROR: " + ex.Message + "\n" + ex.StackTrace);
}
string SQLConnectionString = "Server=*; Database=*; User ID = *; Password=*; Pooling=false;SslMode=None;";
and i'm getting the error :
SQL_ERROR: The type initializer for 'MySql.Data.MySqlClient.MySqlConnectAttrs' threw an exception.
at (wrapper managed-to-native) System.Object.__icall_wrapper_mono_generic_class_init(intptr)
at MySql.Data.MySqlClient.NativeDriver.SetConnectAttrs () [0x00018] in <699dc28794d34867bd2008187eb8039c>:0
at MySql.Data.MySqlClient.Authentication.MySqlAuthenticationPlugin.Authenticate (System.Boolean reset) [0x00080] in <699dc28794d34867bd2008187eb8039c>:0
at MySql.Data.MySqlClient.NativeDriver.Authenticate (System.String authMethod, System.Boolean reset) [0x0002a] in <699dc28794d34867bd2008187eb8039c>:0
at MySql.Data.MySqlClient.NativeDriver.Open () [0x0033f] in <699dc28794d34867bd2008187eb8039c>:0
at MySql.Data.MySqlClient.Driver.Open () [0x0000e] in <699dc28794d34867bd2008187eb8039c>:0
at MySql.Data.MySqlClient.Driver.Create (MySql.Data.MySqlClient.MySqlConnectionStringBuilder settings) [0x0004e] in <699dc28794d34867bd2008187eb8039c>:0
at MySql.Data.MySqlClient.MySqlConnection.Open () [0x0016d] in <699dc28794d34867bd2008187eb8039c>:0
at PlayerXP.PlayerXP.OnEnable () [0x00021] in <80e302c4eac64aeebd42276ff4a14839>:0
I'm running 5.7.25 - MySQL Community Server (GPL)
Server : Localhost with UNIX socket
Protocol version : 10
User : root#localhost
Server char : UTF-8 Unicode (utf8)
Mono JIT compiler version 5.18.0.268
Connector/NET 8.0.15
I use Debian 9.6.
Thanks for your help.
EDIT :
The new error message :
System.TypeInitializationException: The type initializer for 'MySql.Data.MySqlClient.MySqlConnectAttrs' threw an exception. ---> System.IO.FileNotFoundException: Could not load file or assembly 'System.Management, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies.
at MySql.Data.MySqlClient.MySqlConnectAttrs..cctor () [0x0000f] in <699dc28794d34867bd2008187eb8039c>:0
--- End of inner exception stack trace ---
at (wrapper managed-to-native) System.Object.__icall_wrapper_mono_generic_class_init(intptr)
at MySql.Data.MySqlClient.NativeDriver.SetConnectAttrs () [0x00018] in <699dc28794d34867bd2008187eb8039c>:0
at MySql.Data.MySqlClient.Authentication.MySqlAuthenticationPlugin.Authenticate (System.Boolean reset) [0x00080] in <699dc28794d34867bd2008187eb8039c>:0
at MySql.Data.MySqlClient.NativeDriver.Authenticate (System.String authMethod, System.Boolean reset) [0x0002a] in <699dc28794d34867bd2008187eb8039c>:0
at MySql.Data.MySqlClient.NativeDriver.Open () [0x0033f] in <699dc28794d34867bd2008187eb8039c>:0
at MySql.Data.MySqlClient.Driver.Open () [0x0000e] in <699dc28794d34867bd2008187eb8039c>:0
at MySql.Data.MySqlClient.Driver.Create (MySql.Data.MySqlClient.MySqlConnectionStringBuilder settings) [0x0004e] in <699dc28794d34867bd2008187eb8039c>:0
at MySql.Data.MySqlClient.MySqlConnection.Open () [0x0016d] in <699dc28794d34867bd2008187eb8039c>:0
at PlayerXP.PlayerXP.OnEnable () [0x00021] in <cc464d994e5a47c88df91f25374d2f29>:0
Thanks to #Bradley Grainger, my problem is solved. I have tried http://www.nuget.org/packages/MySqlConnector and it works !
I'm trying to add Realm to my app (Xamarin Android). Starting with emulator first (Xaamrin android player - Nexus 5 with Android Lollipop).
Github Issue here
My code:
protected override async void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.MyActivitylayout);
....
try
{
var path = AndroidIoHelper.CreateFileInAppFolder(AndroidIoHelper.GetAppDataFolder(), "tlm_db", "realm");
var realm = Realm.GetInstance(path);
}
catch (Exception ex)
{
Console.WriteLine(ex);
}
.......
}
Exception I'm getting:
Realms.RealmFileAccessErrorException: Operation not permitted at
Realms.NativeCommon.ExceptionThrower (IntPtr exceptionCode, IntPtr
utf8String, IntPtr stringLen) [0x0003b] in :0 at
(wrapper native-to-managed) Realms.NativeCommon:ExceptionThrower
(intptr,intptr,intptr) at (wrapper managed-to-native)
Realms.NativeSharedRealm:open
(Realms.SchemaHandle,string,intptr,intptr,intptr,byte[],ulong) 05-15
12:57:18.384 I/mono-stdout( 5250):
Realms.RealmFileAccessErrorException: Operation not permitted 05-15
12:57:18.384 I/mono-stdout( 5250): at
Realms.NativeCommon.ExceptionThrower (IntPtr exceptionCode, IntPtr
utf8String, IntPtr stringLen) [0x0003b] in :0 05-15
12:57:18.384 I/mono-stdout( 5250): at (wrapper native-to-managed)
Realms.NativeCommon:ExceptionThrower (intptr,intptr,intptr) 05-15
12:57:18.385 I/mono-stdout( 5250): at (wrapper managed-to-native)
Realms.NativeSharedRealm:open
(Realms.SchemaHandle,string,intptr,intptr,intptr,byte[],ulong) 05-15
12:57:18.385 I/mono-stdout( 5250): at Realms.Realm.GetInstance
(Realms.RealmConfiguration config) [0x0010c] in :0
05-15 12:57:18.385 I/mono-stdout( 5250): at Realms.Realm.GetInstance
(System.String databasePath) [0x00019] in :0 05-15
12:57:18.385 I/mono-stdout( 5250): at
MyApp.Activities.SplashScreenActivity+d__4.MoveNext ()
[0x00116] in
C:\Users***\Source\Repos\AppName\MyApp\Activities\SplashScreenActivity.cs:66
at Realms.Realm.GetInstance (Realms.RealmConfiguration config)
[0x0010c] in :0 at Realms.Realm.GetInstance
(System.String databasePath) [0x00019] in :0 at
MyApp.Activities.SplashScreenActivity+d__4.MoveNext ()
[0x00116] in
C:\Users***\Source\Repos\AppName\MyApp\Activities\SplashScreenActivity.cs:66
If I don't specify path I'm getting (var realm = Realm.GetInstance();):
System.ArgumentNullException: Value cannot be null. Parameter name:
type at System.Activator.CreateInstance (System.Type type, Boolean
nonPublic) [0x00006] in
/Users/builder/data/lanes/3053/a94a03b5/source/mono/external/referencesource/mscorlib/system/activator.cs:205
05-15 13:05:05.257 I/mono-stdout( 5474): System.ArgumentNullException:
Value cannot be null. 05-15 13:05:05.257 I/mono-stdout( 5474):
Parameter name: type 05-15 13:05:05.257 I/mono-stdout( 5474): at
System.Activator.CreateInstance (System.Type type, Boolean nonPublic)
[0x00006] in
/Users/builder/data/lanes/3053/a94a03b5/source/mono/external/referencesource/mscorlib/system/activator.cs:205
05-15 13:05:05.257 I/mono-stdout( 5474): at
System.Activator.CreateInstance (System.Type type) [0x00000] in
/Users/builder/data/lanes/3053/a94a03b5/source/mono/external/referencesource/mscorlib/system/activator.cs:147
at System.Activator.CreateInstance (System.Type type) [0x00000] in
/Users/builder/data/lanes/3053/a94a03b5/source/mono/external/referencesource/mscorlib/system/activator.cs:147
at Realms.Realm.CreateRealmObjectMetadata (System.Type
realmObjectType) [0x0001e] in :0 at
System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement]
(IEnumerable1 source, System.Func2 keySelector, System.Func2
elementSelector, IEqualityComparer1 comparer) [0x0004d] in
/Users/builder/data/lanes/3053/a94a03b5/source/mono/external/referencesource/System.Core/System/Linq/Enumerable.cs:855
at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement]
(IEnumerable1 source, System.Func2 keySelector, System.Func2
elementSelector) [0x00000] in
/Users/builder/data/lanes/3053/a94a03b5/source/mono/external/referencesource/System.Core/System/Linq/Enumerable.cs:847
at Realms.Realm..ctor (Realms.SharedRealmHandle sharedRealmHandle,
Realms.RealmConfiguration config) [0x00037] in <filename unknown>:0
at Realms .Realm.GetInstance (Realms.RealmConfiguration config)
[0x00171] in <filename unknown>:0 at
MyApp.Activities.SplashScreenActivity+<OnCreate>d__4.MoveNext ()
[0x00116] in
C:\Users\***\Source\Repos\AppName\MyApp\Activities\SplashScreenActivity.cs:66
05-15 13:05:05.257 I/mono-stdout( 5474): at
Realms.Realm.CreateRealmObjectMetadata (System.Type realmObjectType)
[0x0001e] in <filename unknown>:0 05-15 13:05:05.257 I/mono-stdout(
5474): at System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement]
(IEnumerable1 source, System.Func2 keySelector, System.Func2
elementSelector, IEqualityComparer1 comparer) [0x0004d] in
/Users/builder/data/lanes/3053/a94a03b5/source/mono/external/referencesource/System.Core/System/Linq/Enumerable.cs:855
05-15 13:05:05.257 I/mono-stdout( 5474): at
System.Linq.Enumerable.ToDictionary[TSource,TKey,TElement]
(IEnumerable1 source, System.Func2 keySelector, System.Func2
elementSelector) [0x00000] in
/Users/builder/data/lanes/3053/a94a03b5/source/mono/external/referencesource/System.Core/System/Linq/Enumerable.cs:847
05-15 13:05:05.257 I/mono-stdout( 5474): at Realms.Realm..ctor
(Realms.SharedRealmHandle sharedRealmHandle, Realms.RealmConfiguration
config) [0x00037] in :0 05-15 13:05:05.257
I/mono-stdout( 5474): at Realms.Realm.GetInstance
(Realms.RealmConfiguration config) [0x00171] in :0
05-15 13:05:05.257 I/mono-stdout( 5474): at
MyApp.Activities.SplashScreenActivity+d__4.MoveNext ()
[0x00116] in
C:\Users***\Source\Repos\AppName\MyApp\Activities\SplashScreenActivity.cs:66
The app has Write external storage permission.
Realm and Fody nuget packages installed properly, Fody weavers are present as expected..
It also crashes with same exception using HTC One X with Android 4.2
The above attempt had other issues. There is a real bug currently in Realm with storage on external storage - see the issue https://github.com/realm/realm-dotnet/issues/554 which is proving awkward to debug.
I have a storyboard. Because I load a view in code (depending on conditions) I haven't used the segue anymore. Now I want to load another view but I'm getting the following error:
System.Reflection.TargetInvocationException was thrown
Exception has been thrown by the target of an invocation.
ListButton.TouchUpInside += (object sender, EventArgs e) => {
MyListController myListController = this.Storyboard.InstantiateViewController ("MyListController") as MyListController;
myListController.EdgesForExtendedLayout = UIRectEdge.None;
if (myListController != null) {
this.NavigationController.PushViewController (myListController, true);
}
};
When the button (ListButton) is pressed the view should be loaded onto the navigation stack. The error occurs with InstantiateViewController.
How can I solve that?
Edit:
I went into MyListController and if I comment the following out the view gets loaded:
public MyListController (IntPtr handle) : base (handle)
{
TableView.RegisterClassForCellReuse (typeof(UITableViewCell), listCellId);
TableView.Source = new MyListDataSource (this);
MyList = new List<string> ();
}
Log:
System.Reflection.TargetInvocationException: Exception has been thrown
by the target of an invocation. ---> System.Exception: Object
reference not set to an instance of an object at
TestApp.MyListController.ViewDidLoad () [0x0004c] in
/Users/xxx/Projects/TestApp/TestApp/TestApp/MyListController.cs:78
at at (wrapper managed-to-native)
MonoTouch.ObjCRuntime.Messaging:IntPtr_objc_msgSendSuper
(intptr,intptr) at
MonoTouch.UIKit.UITableViewController.get_TableView () [0x00000] in
:0 at TestApp.MyListController..ctor (IntPtr
handle) [0x00009] in
/Users/xxx/Projects/TestApp/TestApp/TestApp/MyListController.cs:17
at at (wrapper managed-to-native)
System.Reflection.MonoCMethod:InternalInvoke
(System.Reflection.MonoCMethod,object,object[],System.Exception&) at
System.Reflection.MonoCMethod.InternalInvoke (System.Object obj,
System.Object[] parameters) [0x00002] in
/Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:537
--- End of inner exception stack trace --- at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj,
System.Object[] parameters) [0x00016] in
/Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:543
at System.Reflection.MonoCMethod.DoInvoke (System.Object obj,
BindingFlags invokeAttr, System.Reflection.Binder binder,
System.Object[] parameters, System.Globalization.CultureInfo culture)
[0x00095] in
/Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:528
at System.Reflection.MonoCMethod.Invoke (BindingFlags invokeAttr,
System.Reflection.Binder binder, System.Object[] parameters,
System.Globalization.CultureInfo culture) [0x00000] in
/Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Reflection/MonoMethod.cs:556
at System.Reflection.ConstructorInfo.Invoke (System.Object[]
parameters) [0x00000] in
/Developer/MonoTouch/Source/mono/mcs/class/corlib/System.Reflection/ConstructorInfo.cs:62
at MonoTouch.ObjCRuntime.Runtime.ConstructNSObject[NSObject] (IntPtr
ptr, System.Type type, MissingCtorResolution missingCtorResolution)
[0x00000] in :0 at
MonoTouch.ObjCRuntime.Runtime.ConstructNSObject (IntPtr ptr, IntPtr
klass, MissingCtorResolution missingCtorResolution) [0x00000] in
:0 at MonoTouch.ObjCRuntime.Runtime.GetNSObject
(IntPtr ptr, MissingCtorResolution missingCtorResolution) [0x00000] in
:0 at MonoTouch.ObjCRuntime.Runtime.GetNSObject
(IntPtr ptr) [0x00000] in :0 at
MonoTouch.UIKit.UIStoryboard.InstantiateViewController (System.String
identifier) [0x00000] in :0 at
TestApp.StartScreenViewController.m__1 (System.Object
sender, System.EventArgs e) [0x0000c] in
/Users/xxx/Projects/TestApp/TestApp/TestApp/StartScreenViewController.cs:57
at MonoTouch.UIKit.UIControlEventProxy.Activated () [0x00000] in
:0 at at (wrapper managed-to-native)
MonoTouch.UIKit.UIApplication:UIApplicationMain
(int,string[],intptr,intptr) at MonoTouch.UIKit.UIApplication.Main
(System.String[] args, System.String principalClassName, System.String
delegateClassName) [0x00000] in :0 at
TestApp.Application.Main (System.String[] args) [0x00008] in
/Users/xxx/Projects/TestApp/TestApp/TestApp/Main.cs:17
Try:
Hmm, now I added a new UITableViewController to the storyboard, changed some classes to public, changed variable names to starting with lower case. Also the old UITableviewController had a problem with an added SearchController. Now I made everything new and the problem only relied in the viewDidLoad but that was not the original problem. It was one of these steps (perhaps the SearchController problem).
Problematic Code:
this.NavigationController.ToolbarHidden = false;
It seems that he can't find the NavigationController ... How do I addd the navigation controller to the new created view?
I'm attempting to extend the generic ArrayAdapter in order to customize a ListView and am getting an NoSuchMethodError being thrown when I hit the TpAdapter (my extended Adapter) constructor
Here is the exteded ArrayAdapter TpAdapter
private class TpAdapter : ArrayAdapter<MobileTalkingPoint>
{
private MobileTalkingPoint[] items;
private Context outer_context;
public TpAdapter(Context context, int textViewResourceId, MobileTalkingPoint[] items)
: base(context, textViewResourceId, items)
{
this.items = items;
this.outer_context = context;
}
public override View GetView(int position, View convertView, ViewGroup parent)
{
View v = convertView;
if (v == null)
{
LayoutInflater vi = (LayoutInflater)outer_context.GetSystemService(Context.LayoutInflaterService);
v = vi.Inflate(Resource.Layout.ItemTalkingPoint, null);
}
MobileTalkingPoint tp = items[position];
if (tp != null)
{
TextView tpDate = v.FindViewById<TextView>(Resource.Id.tpDate);
TextView tpTitle = v.FindViewById<TextView>(Resource.Id.tpTitle);
TextView tpType = v.FindViewById<TextView>(Resource.Id.tpType);
TextView tpBody = v.FindViewById<TextView>(Resource.Id.tpBody);
tpDate.Text = String.Format("{0:MM/dd/yy}", tp.TPDate);
tpTitle.Text = tp.Title;
tpType.Text = tp.Type;
tpBody.Text = tp.Descr;
}
return v;
}
}
I am instantiating them as follows in the activity:
MobileTalkingPoint[] weaknesses = talkingPoints;
TpAdapter adapStrength = new TpAdapter(this, Resource.Layout.ItemTalkingPoint, strengths);
And the stacktrace for the exception is as follows
I/ActivityManager( 1283): Starting: Intent { cmp=MapDroid.MapDroid/mapdroid.TabbedView (has extras) } from pid 22409
I/ActivityManager( 1283): Displayed MapDroid.MapDroid/mapdroid.TabbedView: +573ms
D/dalvikvm(22409): GetMethodID: method not found: Lmapdroid/TabTalkingPoints_TpAdapter;.<init>:(Landroid/content/Context;I[Ljava/lang/Object;)V
I/MonoDroid(22409): UNHANDLED EXCEPTION: Java.Lang.NoSuchMethodError: Exception of type 'Java.Lang.NoSuchMethodError' was thrown.
I/MonoDroid(22409): at Android.Runtime.JNIEnv.GetMethodID (intptr,string,string) <0x0007c>
I/MonoDroid(22409): at Android.Widget.ArrayAdapter`1<MonoMap.wsMobile.MobileTalkingPoint>..ctor (Android.Content.Context,int,MonoMap.wsMobile.MobileTalkingPoint[]) <0x0027b>
I/MonoDroid(22409): at MapDroid.TabTalkingPoints/TpAdapter..ctor (Android.Content.Context,int,MonoMap.wsMobile.MobileTalkingPoint[]) <0x0002b>
I/MonoDroid(22409): at MapDroid.TabTalkingPoints.ShowList () <0x00077>
I/MonoDroid(22409): at MapDroid.TabTalkingPoints.OnCreate (Android.OS.Bundle) <0x001df>
I/MonoDroid(22409): at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_ (intptr,intptr,intptr) <0x00057>
I/MonoDroid(22409): at (wrapper dynamic-method) object.b1cd4072-05f5-4443-8835-b4102b462c1e (intptr,intptr,intptr) <0x00033>
I/MonoDroid(22409):
I/MonoDroid(22409): --- End of managed exception stack trace ---
I/MonoDroid(22409): java.lang.NoSuchMethodError: <init>
I/MonoDroid(22409): at mapdroid.TabTalkingPoints.n_onCreate(Native Method)
I/MonoDroid(22409): at mapdroid.TabTalkingPoints.onCreate(TabTalkingPoints.java:25)
I/MonoDroid(22409): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
I/MonoDroid(22409): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1722)
I/MonoDroid(22409): at android.app.ActivityThread.startActivityNow(ActivityThread.java:1598)
I/MonoDroid(22409): at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:127)
I/MonoDroid(22409): at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:339)
I/MonoDroid(22409): at android.widget.TabHost$IntentContentStrategy.getContentView(TabHost.java:654)
I/MonoDroid(22409): at android.widget.TabHost.setCurrentTab(TabHost.java:326)
I/MonoDroid(22409): at android.widget.TabHost$2.onTabSelectionChanged(TabHost.java:132)
I/MonoDroid(22409): at android.widget.TabWidget$TabClickListener.onClick(TabWidget.java:455)
I/MonoDroid(22409): at android.view.View.performClick(View.java:2501)
I/MonoDroid(22409): at android.view.View$PerformClick.run(View.java:9107)
I/MonoDroid(22409): at android.os.Handler.handleCallback(Handler.java:587)
I/MonoDroid(22409): at android.os.Handler.dispatchMessage(Handler.java:92)
I/MonoDroid(22409): at android.os.Looper.loop(Looper.java:123)
I/MonoDroid(22409): at android.app.ActivityThread.main(ActivityThread.java:3835)
I/MonoDroid(22409): at java.lang.reflect.Method.invokeNative(Native Method)
I/MonoDroid(22409): at java.lang.reflect.Method.invoke(Method.java:507)
I/MonoDroid(22409): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841)
I/MonoDroid(22409): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599)
I/MonoDroid(22409): at dalvik.system.NativeStart.main(Native Method)
E/mono (22409):
E/mono (22409): Unhandled Exception: Java.Lang.NoSuchMethodError: Exception of type 'Java.Lang.NoSuchMethodError' was thrown.
E/mono (22409): at Android.Runtime.JNIEnv.GetMethodID (IntPtr kls, System.String name, System.String signature) [0x00000] in <filename unknown>:0
E/mono (22409): at Android.Widget.ArrayAdapter`1[MonoMap.wsMobile.MobileTalkingPoint]..ctor (Android.Content.Context context, Int32 textViewResourceId, MonoMap.wsMobile.MobileTalkingPoint[] objects) [0x00000] in <filename unknown>:0
E/mono (22409): at MapDroid.TabTalkingPoints+TpAdapter..ctor (Android.Content.Context context, Int32 textViewResourceId, MonoMap.wsMobile.MobileTalkingPoint[] items) [0x00000] in <filename unknown>:0
E/mono (22409): at MapDroid.TabTalkingPoints.ShowList () [0x00000] in <filename unknown>:0
E/mono (22409): at MapDroid.TabTalkingPoints.OnCreate (Android.OS.Bundle bundle) [0x00000] in <filename unknown>:0
E/mono (22409): at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_ (IntPtr jnienv, IntPtr native__this, IntPtr native_savedInstanceState) [0x00000] in <filename unknown>:0
E/mono (22409): at (wrapper dynamic-method)
I/ActivityManager( 1283): Process MapDroid.MapDroid (pid 22409) has died.
NOTE I am using Mono for Android with Visual Studio 2010
I'm not sure if this is a bug in Mono For Android or not (seems like it might be, though), but if you modify your adapter to take in an IList instead of an array, the problem goes away:
private class TpAdapter : ArrayAdapter<MobileTalkingPoint>
{
public TpAdapter(Context context, int textViewResourceId, IList<MobileTalkingPoint> items)
: base(context, textViewResourceId, items)
{
}
}
You can still call it using an array, so that doesn't need to be modified:
MobileTalkingPoint[] points = { };
TpAdapter adapStrength = new TpAdapter(this, Resource.Layout.ItemTalkingPoint, points);