I'm using lib MySql.Data to try connect and insert some data in a table but
My Code:
using System;
using System.Data;
using MySql.Data.MySqlClient;
public class DBCon
{
public static class Banco
{
public static async void Executar(string query)
{
var connection = new MySqlConnection("Server=XXXXXXX;Database=YYYYYYYYY;Uid=ZZZZZZZ;Pwd=PPPPPPPPP");
var command = connection.CreateCommand();
try
{
connection.Open();
command.CommandText = query;
command.ExecuteNonQuery();
}
catch(Exception)
{
throw;
}
finally
{
if (connection.State == ConnectionState.Open)
connection.Close();
}
}
}
}
Executing the query:
DBCon.Banco.Executar("INSERT INTO table (device,latitude,longitude) VALUES ('abc123','"+position.Latitude+"','"+position.Longitude+"')");
Getting these lines while debugging:
10-12 00:41:32.931 E/mono (12296):
10-12 00:41:32.931 E/mono (12296): Unhandled Exception:
10-12 00:41:32.931 E/mono (12296): System.TypeInitializationException: The type initializer for 'MySql.Data.MySqlClient.Replication.ReplicationManager' threw an exception.
---> System.TypeInitializationException: The type initializer for 'MySql.Data.MySqlClient.MySqlConfiguration' threw an exception.
---> System.Configuration.ConfigurationErrorsException: Configuration system failed to initialize
---> System.PlatformNotSupportedException: Operation is not supported on this platform.
10-12 00:41:32.931 E/mono (12296): at System.Configuration.ClientConfigPaths..ctor (System.String exePath, System.Boolean includeUserConfig) [0x00050] in <0e721f564ffa49e6b1d97ad7b9fda1f2>:0 10-12 00:41:32.931 E/mono (12296): at System.Configuration.ClientConfigPaths.GetPaths (System.String exePath, System.Boolean includeUserConfig) [0x00018] in <0e721f564ffa49e6b1d97ad7b9fda1f2>:0 10-12 00:41:32.931 E/mono (12296): at System.Configuration.ClientConfigurationHost.get_ConfigPaths () [0x0000a] in <0e721f564ffa49e6b1d97ad7b9fda1f2>:0 10-12 00:41:32.931 E/mono (12296): at System.Configuration.ClientConfigurationHost.GetStreamName (System.String configPath) [0x0006d] in <0e721f564ffa49e6b1d97ad7b9fda1f2>:0 10-12 00:41:32.931 E/mono (12296): at System.Configuration.ClientConfigurationHost.get_IsAppConfigHttp () [0x00000] in <0e721f564ffa49e6b1d97ad7b9fda1f2>:0 10-12 00:41:32.931 E/mono (12296): at System.Configuration.Internal.DelegatingConfigHost.get_IsAppConfigHttp () [0x00006] in <0e721f564ffa49e6b1d97ad7b9fda1f2>:0 10-12 00:41:32.931 E/mono (12296): at System.Configuration.ClientConfigurationSystem..ctor () [0x00051] in <0e721f564ffa49e6b1d97ad7b9fda1f2>:0 10-12 00:41:32.931 E/mono (12296): at System.Configuration.ConfigurationManager.EnsureConfigurationSystem () [0x00024] in <0e721f564ffa49e6b1d97ad7b9fda1f2>:0 10-12 00:41:32.931 E/mono (12296): --- End of inner exception stack trace --- 10-12 00:41:32.931 E/mono (12296): at System.Configuration.ConfigurationManager.EnsureConfigurationSystem () [0x00060] in <0e721f564ffa49e6b1d97ad7b9fda1f2>:0 10-12 00:41:32.931 E/mono (12296): at System.Configuration.ConfigurationManager.PrepareConfigSystem () [0x0000a] in <0e721f564ffa49e6b1d97ad7b9fda1f2>:0 10-12 00:41:32.931 E/mono (12296): at System.Configuration.ConfigurationManager.GetSection (System.String sectionName) [0x0000a] in <0e721f564ffa49e6b1d97ad7b9fda1f2>:0 10-12 00:41:32.931 E/mono (12296): at MySql.Data.MySqlClient.MySqlConfiguration..cctor () [0x00000] in <8d19be5077ed43c6a3a11313ef774535>:0 10-12 00:41:32.931 E/mono (12296): --- End of inner exception stack trace --- 10-12 00:41:32.931 E/mono (12296): at MySql.Data.MySqlClient.Replication.ReplicationManager..cctor () [0x0001e] in <8d19be5077ed43c6a3a11313ef774535>:0 10-12 00:41:32.931 E/mono (12296): --- End of inner exception stack trace --- 10-12 00:41:32.931 E/mono (12296): at MySql.Data.MySqlClient.MySqlConnection.Open () [0x0016d] in <8d19be5077ed43c6a3a11313ef774535>:0 10-12 00:41:32.931 E/mono (12296): at DBCon+Banco+<Executar>d__0.MoveNext () [0x00059] in D:\apps\BatePapo\BatePapo\BatePapo\DBCon.cs:22 10-12 00:41:32.931 E/mono (12296): --- End of stack trace from previous location where exception was thrown --- 10-12 00:41:32.931 E/mono (12296): at (wrapper dynamic-method) System.Object.47(intptr,intptr) 10-12 00:41:32.932 E/mono-rt (12296): [ERROR] FATAL UNHANDLED EXCEPTION: System.TypeInitializationException: The type initializer for 'MySql.Data.MySqlClient.Replication.ReplicationManager' threw an exception. ---> System.TypeInitializationException: The type initializer for 'MySql.Data.MySqlClient.MySqlConfiguration' threw an exception. ---> System.Configuration.ConfigurationErrorsException: Configuration system failed to initialize ---> System.PlatformNotSupportedException: Operation is not supported on this platform. 10-12 00:41:32.932 E/mono-rt (12296): at System.Configuration.ClientConfigPaths..ctor (System.String exePath, System.Boolean includeUserConfig) [0x00050] in <0e721f564ffa49e6b1d97ad7b9fda1f2>:0 10-12 00:41:32.932 E/mono-rt (12296): at System.Configuration.ClientConfigPaths.GetPaths (System.String exePath, System.Boolean includeUserConfig) [0x00018] in <0e721f564ffa49e6b1d97ad7b9fda1f2>:0 10-12 00:41:32.932 E/mono-rt (12296): at System.Configuration.ClientConfigurationHost.get_ConfigPaths () [0x0000a] in <0e721f564ffa49e6b1d97ad7b9fda1f2>:0 10-12 00:41:32.932 E/mono-rt (12296): at System.Configuration.ClientConfigurationHost.GetStreamName (System.String configPath) [0x0006d] in <0e721f564ffa49e6b1d97ad7b9fda1f2>:0 10-12 00:41:32.932 E/mono-rt (12296): at System.Configuration.ClientConfigurationHost.get_IsAppConfigHttp () [0x00000] in <0e721f564ffa49e6b1d97ad7b9fda1f2>:0 10-12 00:41:32.932 E/mono-rt (12296): at System.Configuration.Internal.DelegatingConfigHost.get_IsAppConfigHttp () [0x00006] in <0e721f564ffa49e6b1d97ad7b9fda1f2>:0 10-12 00:41:32.932 E/mono-rt (12296): at System.Configuration.ClientConfigurationSystem..ctor () [0x00051] in <0e721f564ffa49e6b1d97ad7b9fda1f2>:0 10-12 00:41:32.932 E/mono-rt (12296): at System.Configuration.ConfigurationManager.EnsureConfigurationSystem () [0x00024] in <0e721f564ffa49e6b1d97ad7b9fda1f2>:0 10-12 00:41:32.932 E/mono-rt (12296): --- End of inner exception stack trace --- 10-12 00:41:32.932 E/mono-rt (12296): at System.Configuration.ConfigurationManager.EnsureConfigurationSystem () [0x00060] in <0e721f564ffa49e6b1d97ad7b9fda1f2>:0 10-12 00:41:32.932 E/mono-rt (12296): at System.Configuration.ConfigurationManager.PrepareConfigSystem () [0x0000a] in <0e721f564ffa49e6b1d97ad7b9fda1f2>:0 10-12 00:41:32.932 E/mono-rt (12296): at System.Configuration.ConfigurationManager.GetSection (System.String sectionName) [0x0000a] in <0e721f564ffa49e6b1d97ad7b9fda1f2>:0 10-12 00:41:32.932 E/mono-rt (12296): at MySql.Data.MySqlClient.MySqlConfiguration..cctor () [0x00000] in <8d19be5077ed43c6a3a11313ef774535>:0 10-12 00:41:32.932 E/mono-rt (12296): --- End of inner exception stack trace --- 10-12 00:41:32.932 E/mono-rt (12296): at MySql.Data.MySqlClient.Replication.ReplicationManager..cctor () [0x0001e] in <8d19be5077ed43c6a3a11313ef774535>:0 10-12 00:41:32.932 E/mono-rt (12296): --- End of inner exception stack trace --- 10-12 00:41:32.932 E/mono-rt (12296): at MySql.Data.MySqlClient.MySqlConnection.Open () [0x0016d] in <8d19be5077ed43c6a3a11313ef774535>:0 10-12 00:41:32.932 E/mono-rt (12296): at DBCon+Banco+<Executar>d__0.MoveNext () [0x00059] in D:\apps\BatePapo\BatePapo\BatePapo\DBCon.cs:22 10-12 00:41:32.932 E/mono-rt (12296): --- End of stack trace from previous location where exception was thrown --- 10-12 00:41:32.932 E/mono-rt (12296): at (wrapper dynamic-method) System.Object.47(intptr,intptr) 10-12 00:41:32.935 D/ (12296): HostConnection::get() New Host Connection established 0xd02c5500, tid 12296
Can anyone see what is the error?
Related
I'm a linux (Slackware 14.2) user and needed to install mono for a work project on my computer. After installing the slackbuild I ran the code from https://www.mono-project.com/docs/getting-started/mono-basics/ which worked great until I tried to use 'System.Windows.Forms' as follow:
using System;
using System.Windows.Forms;
public class HelloWorld : Form
{
static public void Main ()
{
Application.Run (new HelloWorld ());
}
public HelloWorld ()
{
Text = "Hello Mono World";
}
}
After compiling and running I get:
$ mono hello.exe
Unhandled Exception:
System.TypeInitializationException: The type initializer for 'System.Windows.Forms.WindowsFormsSynchronizationContext' threw an exception. ---> System.TypeInitializationException: The type initializer for 'System.Windows.Forms.ThemeEngine' threw an exception. ---> System.TypeInitializationException: The type initializer for 'System.Windows.Forms.ThemeWin32Classic' threw an exception. ---> System.TypeInitializationException: The type initializer for 'System.Drawing.KnownColors' threw an exception. ---> System.TypeInitializationException: The type initializer for 'System.Drawing.GDIPlus' threw an exception. ---> System.DllNotFoundException: libgdiplus.so.0
at (wrapper managed-to-native) System.Drawing.GDIPlus:GdiplusStartup (ulong&,System.Drawing.GdiplusStartupInput&,System.Drawing.GdiplusStartupOutput&)
at System.Drawing.GDIPlus..cctor () [0x000ab] in <ac0a7ab7ad9c4534aa7b9d68ccc688c1>:0
--- End of inner exception stack trace ---
at System.Drawing.KnownColors..cctor () [0x0001a] in <ac0a7ab7ad9c4534aa7b9d68ccc688c1>:0
--- End of inner exception stack trace ---
at System.Drawing.Color.get_Black () [0x00000] in <ac0a7ab7ad9c4534aa7b9d68ccc688c1>:0
at System.Windows.Forms.ThemeWin32Classic..cctor () [0x00000] in <cfc91f7a5a0243dda6f0da9f9f2bd749>:0
--- End of inner exception stack trace ---
at System.Windows.Forms.ThemeEngine..cctor () [0x0002f] in <cfc91f7a5a0243dda6f0da9f9f2bd749>:0
--- End of inner exception stack trace ---
at System.Windows.Forms.SystemInformation.get_MenuAccessKeysUnderlined () [0x00000] in <cfc91f7a5a0243dda6f0da9f9f2bd749>:0
at System.Windows.Forms.Control..ctor () [0x000e4] in <cfc91f7a5a0243dda6f0da9f9f2bd749>:0
at (wrapper remoting-invoke-with-check) System.Windows.Forms.Control:.ctor ()
at System.Windows.Forms.WindowsFormsSynchronizationContext..cctor () [0x00000] in <cfc91f7a5a0243dda6f0da9f9f2bd749>:0
--- End of inner exception stack trace ---
at System.Windows.Forms.Control..ctor () [0x00014] in <cfc91f7a5a0243dda6f0da9f9f2bd749>:0
at System.Windows.Forms.ScrollableControl..ctor () [0x00000] in <cfc91f7a5a0243dda6f0da9f9f2bd749>:0
at System.Windows.Forms.ContainerControl..ctor () [0x0000e] in <cfc91f7a5a0243dda6f0da9f9f2bd749>:0
at System.Windows.Forms.Form..ctor () [0x00012] in <cfc91f7a5a0243dda6f0da9f9f2bd749>:0
at HelloWorld..ctor () [0x00000] in <ebd84f70eef34e1bac9228a36ebc3550>:0
at (wrapper remoting-invoke-with-check) HelloWorld:.ctor ()
at HelloWorld.Main () [0x00001] in <ebd84f70eef34e1bac9228a36ebc3550>:0
[ERROR] FATAL UNHANDLED EXCEPTION: System.TypeInitializationException: The type initializer for 'System.Windows.Forms.WindowsFormsSynchronizationContext' threw an exception. ---> System.TypeInitializationException: The type initializer for 'System.Windows.Forms.ThemeEngine' threw an exception. ---> System.TypeInitializationException: The type initializer for 'System.Windows.Forms.ThemeWin32Classic' threw an exception. ---> System.TypeInitializationException: The type initializer for 'System.Drawing.KnownColors' threw an exception. ---> System.TypeInitializationException: The type initializer for 'System.Drawing.GDIPlus' threw an exception. ---> System.DllNotFoundException: libgdiplus.so.0
at (wrapper managed-to-native) System.Drawing.GDIPlus:GdiplusStartup (ulong&,System.Drawing.GdiplusStartupInput&,System.Drawing.GdiplusStartupOutput&)
at System.Drawing.GDIPlus..cctor () [0x000ab] in <ac0a7ab7ad9c4534aa7b9d68ccc688c1>:0
--- End of inner exception stack trace ---
at System.Drawing.KnownColors..cctor () [0x0001a] in <ac0a7ab7ad9c4534aa7b9d68ccc688c1>:0
--- End of inner exception stack trace ---
at System.Drawing.Color.get_Black () [0x00000] in <ac0a7ab7ad9c4534aa7b9d68ccc688c1>:0
at System.Windows.Forms.ThemeWin32Classic..cctor () [0x00000] in <cfc91f7a5a0243dda6f0da9f9f2bd749>:0
--- End of inner exception stack trace ---
at System.Windows.Forms.ThemeEngine..cctor () [0x0002f] in <cfc91f7a5a0243dda6f0da9f9f2bd749>:0
--- End of inner exception stack trace ---
at System.Windows.Forms.SystemInformation.get_MenuAccessKeysUnderlined () [0x00000] in <cfc91f7a5a0243dda6f0da9f9f2bd749>:0
at System.Windows.Forms.Control..ctor () [0x000e4] in <cfc91f7a5a0243dda6f0da9f9f2bd749>:0
at (wrapper remoting-invoke-with-check) System.Windows.Forms.Control:.ctor ()
at System.Windows.Forms.WindowsFormsSynchronizationContext..cctor () [0x00000] in <cfc91f7a5a0243dda6f0da9f9f2bd749>:0
--- End of inner exception stack trace ---
at System.Windows.Forms.Control..ctor () [0x00014] in <cfc91f7a5a0243dda6f0da9f9f2bd749>:0
at System.Windows.Forms.ScrollableControl..ctor () [0x00000] in <cfc91f7a5a0243dda6f0da9f9f2bd749>:0
at System.Windows.Forms.ContainerControl..ctor () [0x0000e] in <cfc91f7a5a0243dda6f0da9f9f2bd749>:0
at System.Windows.Forms.Form..ctor () [0x00012] in <cfc91f7a5a0243dda6f0da9f9f2bd749>:0
at HelloWorld..ctor () [0x00000] in <ebd84f70eef34e1bac9228a36ebc3550>:0
at (wrapper remoting-invoke-with-check) HelloWorld:.ctor ()
at HelloWorld.Main () [0x00001] in <ebd84f70eef34e1bac9228a36ebc3550>:0
Is there anything I did wrong (or didn't do)?
Didn't notice I had a 32-bit lib installed. Perfectly working now.
Thanks Stefan Becker.
i am new to Xamairin form development, i have list of items value and i want to fetch subitems collections in order to items id , so i looped items and inside the loop just call HttpClient get request to fetch subitems and doing some add to another list to display listview with header template, the issue is when i call httpclient inside loop 1st time it fetch the data and the next time it has thorwn System.Net.Http.HttpRequestException: An error occurred while sending the request
can you any one help me, how od i overcome this
11-06 16:44:32.517 I/MonoDroid(13270): UNHANDLED EXCEPTION:
11-06 16:44:32.522 I/MonoDroid(13270): System.Net.Http.HttpRequestException: An error occurred while sending the request ---> System.Net.WebException: Error: NameResolutionFailure
11-06 16:44:32.522 I/MonoDroid(13270): at System.Net.HttpWebRequest.EndGetResponse (System.IAsyncResult asyncResult) [0x00058] in <5a97d41d36694fb19855c17429527b10>:0
11-06 16:44:32.522 I/MonoDroid(13270): at System.Threading.Tasks.TaskFactory1[TResult].FromAsyncCoreLogic (System.IAsyncResult iar, System.Func2[T,TResult] endFunction, System.Action1[T] endAction, System.Threading.Tasks.Task1[TResult] promise, System.Boolean requiresSynchronization) [0x0000f] in :0
11-06 16:44:32.522 I/MonoDroid(13270): --- End of stack trace from previous location where exception was thrown ---
11-06 16:44:32.522 I/MonoDroid(13270): at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in :0
11-06 16:44:32.522 I/MonoDroid(13270): at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in :0
11-06 16:44:32.522 I/MonoDroid(13270): at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in :0
11-06 16:44:32.522 I/MonoDroid(13270): at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in :0
11-06 16:44:32.522 I/MonoDroid(13270): at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in <f32579baafc1404fa37ba3ec1abdc0bd>:0
11-06 16:44:32.522 I/MonoDroid(13270): at System.Net.Http.HttpClientHandler+<SendAsync>d__64.MoveNext () [0x0041d] in <996a681f30a44cd685a4da54e11956e2>:0
11-06 16:44:32.522 I/MonoDroid(13270): --- End of inner exception stack trace ---
11-06 16:44:32.522 I/MonoDroid(13270): at System.Net.Http.HttpClientHandler+<SendAsync>d__64.MoveNext () [0x00478] in <996a681f30a44cd685a4da54e11956e2>:0
11-06 16:44:32.522 I/MonoDroid(13270): --- End of stack trace from previous location where exception was thrown ---
11-06 16:44:32.522 I/MonoDroid(13270): at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <f32579baafc1404fa37ba3ec1abdc0bd>:0
11-06 16:44:32.522 I/MonoDroid(13270): at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <f32579baafc1404fa37ba3ec1abdc0bd>:0
11-06 16:44:32.522 I/MonoDroid(13270): at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <f32579baafc1404fa37ba3ec1abdc0bd>:0
11-06 16:44:32.522 I/MonoDroid(13270): at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <f32579baafc1404fa37ba3ec1abdc0bd>:0
11-06 16:44:32.522 I/MonoDroid(13270): at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in :0
11-06 16:44:32.522 I/MonoDroid(13270): at System.Net.Http.HttpClient+d__49.MoveNext () [0x000ca] in <996a681f30a44cd685a4da54e11956e2>:0
11-06 16:44:32.522 I/MonoDroid(13270): --- End of stack trace from previous location where exception was thrown ---
11-06 16:44:32.522 I/MonoDroid(13270): at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in :0
11-06 16:44:32.522 I/MonoDroid(13270): at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in :0
11-06 16:44:32.522 I/MonoDroid(13270): at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in :0
11-06 16:44:32.523 I/MonoDroid(13270): at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in :0
11-06 16:44:32.523 I/MonoDroid(13270): at System.Runtime.CompilerServices.ConfiguredTaskAwaitable1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in <f32579baafc1404fa37ba3ec1abdc0bd>:0
11-06 16:44:32.523 I/MonoDroid(13270): at Expertential.Services.ActivityTaskListViewModelService+<GetActivityList>d__9.MoveNext () [0x0012b] in E:\RNSTFS\Expertential Mobile\Expertential.Mobile\Expertential\Expertential\Services\ActivityTaskListViewModelService.cs:66
11-06 16:44:32.523 I/MonoDroid(13270): --- End of stack trace from previous location where exception was thrown ---
11-06 16:44:32.523 I/MonoDroid(13270): at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in <f32579baafc1404fa37ba3ec1abdc0bd>:0
11-06 16:44:32.523 I/MonoDroid(13270): at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <f32579baafc1404fa37ba3ec1abdc0bd>:0
11-06 16:44:32.523 I/MonoDroid(13270): at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <f32579baafc1404fa37ba3ec1abdc0bd>:0
11-06 16:44:32.523 I/MonoDroid(13270): at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <f32579baafc1404fa37ba3ec1abdc0bd>:0
11-06 16:44:32.523 I/MonoDroid(13270): at System.Runtime.CompilerServices.TaskAwaiter1[TResult].GetResult () [0x00000] in :0
11-06 16:44:32.523 I/MonoDroid(13270): at Expertential.ViewModels.DashBoardViewModel+d__74.MoveNext () [0x000df] in E:\RNSTFS\Expertential Mobile\Expertential.Mobile\Expertential\Expertential\ViewModels\DashBoardViewModel.cs:325
11-06 16:44:32.523 I/MonoDroid(13270): --- End of stack trace from previous location where exception was thrown ---
11-06 16:44:32.523 I/MonoDroid(13270): at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in :0
11-06 16:44:32.523 I/MonoDroid(13270): at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.b__6_0 (System.Object state) [0x00000] in :0
11-06 16:44:32.523 I/MonoDroid(13270): at Android.App.SyncContext+<>c__DisplayClass2_0.b__0 () [0x00000] in <263adecfa58f4c449f1ff56156d886fd>:0
11-06 16:44:32.523 I/MonoDroid(13270): at Java.Lang.Thread+RunnableImplementor.Run () [0x00008] in <263adecfa58f4c449f1ff56156d886fd>:0
11-06 16:44:32.523 I/MonoDroid(13270): at Java.Lang.IRunnableInvoker.n_Run (System.IntPtr jnienv, System.IntPtr native__this) [0x00008] in <263adecfa58f4c449f1ff56156d886fd>:0
11-06 16:44:32.523 I/MonoDroid(13270): at (wrapper dynamic-method) System.Object.91b49edf-9891-4d0a-b0ee-998e603a63ec(intptr,intptr)
11-06 16:44:32.537 W/art (13270): JNI RegisterNativeMethods: attempt to register 0 native methods for android.runtime.JavaProxyThrowable
11-06 16:44:32.542 D/Mono (13270): DllImport searching in: '__Internal' ('(null)').
11-06 16:44:32.542 D/Mono (13270): Searching for 'java_interop_jnienv_throw'.
11-06 16:44:32.542 D/Mono (13270): Probing 'java_interop_jnienv_throw'.
11-06 16:44:32.542 D/Mono (13270): Found as 'java_interop_jnienv_throw'.
An unhandled exception occured.
here is my code ViewModel class
public async void GetToday(DateTime filterdate, ObservableCollection<TodaysActivity> TodaysActivityList)
{
var count = 0;
ObservableCollection<TodaysProjectList> ne = new ObservableCollection<TodaysProjectList>();
activityTaskListViewModelService = new ActivityTaskListViewModelService();
foreach(TodaysActivity act in TodaysActivityList)
{
count = count + 1;
TodaysProjectList t = new TodaysProjectList()
{
clientName = act.clientName,
projectNick = act.projectNick,
DashboardActivitys = await activityTaskListViewModelService.GetActivityList(filterdate, act.projectId)
};
ne.Add(t);
// return;
}
Todays = todays;
}
Service class
public async Task<ObservableCollection<DashboardActivity>> GetActivityList(DateTime filterDate, int projectId)
{
if (CrossConnectivity.Current.IsConnected)
{
ObservableCollection<DashboardActivity> activityList = new ObservableCollection<DashboardActivity>();
string token = "";
if (Application.Current.Properties.ContainsKey("TOKEN_AUTH"))
{
token = Application.Current.Properties["TOKEN_AUTH"].ToString();
}
_client = new HttpClient();
_client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", token);
getUrlActivity = constDomain + getUrlActivity;
var response = await _client.GetAsync(getUrlActivity + filterDate.ToString("MM/dd/yyyy") + "&projectId=" + projectId.ToString()).ConfigureAwait(true); //projectId=8113&activityId=817411
_client.Dispose();
if (response.IsSuccessStatusCode)
{
var str = await response.Content.ReadAsStringAsync();
dynamic attachment = JsonConvert.DeserializeObject(str);
var model = JsonConvert.DeserializeObject<List<DashboardActivity>>(str);
activityList = new ObservableCollection<DashboardActivity>(model);
for(int i=0;i<activityList.Count;i++)
{
var innerObj = attachment[i].attachments;
var obj = innerObj.ToObject<List<Attachments>>();
activityList[i].attachements = obj;
}
return activityList;
}
return null;
}
return null;
}
I am trying to create a mobile application using MvvmCross v.4.4.0.
Application works correct. But if collapse application and lock the phone, and then unlock and press "Overview" android button application crash (only on the Xiaomi phone).
I think android kills activity and then unsuccessfully trying to recreate it.
Could you, please explain me, what I do wrong? How to fix it?
Stacktrace:
Android.Runtime.RaiseThrowableEventArgs MvvmCross.Platform.Exceptions.MvxException: Failed to construct and initialize ViewModel for type Test.Core.ViewModels.MainMenuViewModel from locator MvxDefaultViewModelLocator - check InnerException for more information ---> MvvmCross.Platform.Exceptions.MvxException: Problem creating viewModel of type MainMenuViewModel ---> MvvmCross.Platform.Exceptions.MvxIoCResolveException: Failed to construct MainMenuViewModel ---> System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> Java.Lang.LinkageError: no static method "Landroid/text/Html;.fromHtml(Ljava/lang/String;I)Landroid/text/Spanned;" at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw ()
[0x0000c] in <89dd20b27a0b473a848558c84f1f086a>:0 at Java.Interop.JniEnvironment+StaticMethods.GetStaticMethodID (Java.Interop.JniObjectReference type, System.String name, System.String signature)
[0x00068] in :0 at Java.Interop.JniType.GetStaticMethod (System.String name, System.String signature)
[0x0000d] in :0 at Java.Interop.JniPeerMembers+JniStaticMethods.GetMethodInfo (System.String encodedMember)
[0x0003c] in :0 at Java.Interop.JniPeerMembers+JniStaticMethods.InvokeObjectMethod (System.String encodedMember, Java.Interop.JniArgumentValue* parameters)
[0x00001] in :0 at Android.Text.Html.FromHtml (System.String source, Android.Text.FromHtmlOptions flags)
[0x0003b] in :0 at Test.Droid.Providers.DialogProvider.ShowSnackbar () [0x00017] in <0fa1f44ee2f748fe816e790571c2153b>:0 at Test.Core.ViewModels.BaseViewModel..ctor ()
[0x0006d] in :0 at Test.Core.ViewModels.MainMenuViewModel..ctor (Test.Core.Managers.IExceptionManager exceptionManager)
[0x0000b] in :0 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 <89dd20b27a0b473a848558c84f1f086a>:0 --- End of inner exception stack trace --- at System.Reflection.MonoCMethod.InternalInvoke (System.Object obj, System.Object[] parameters)
[0x0001c] in <89dd20b27a0b473a848558c84f1f086a>:0 at System.Reflection.MonoCMethod.DoInvoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture)
[0x00089] in <89dd20b27a0b473a848558c84f1f086a>:0 at System.Reflection.MonoCMethod.Invoke (System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture)
[0x00000] in <89dd20b27a0b473a848558c84f1f086a>:0 at System.Reflection.ConstructorInfo.Invoke (System.Object[] parameters)
[0x00000] in <89dd20b27a0b473a848558c84f1f086a>:0 at MvvmCross.Platform.IoC.MvxSimpleIoCContainer.IoCConstruct (System.Type type)
[0x0003a] in <4ddde23419c5494288c799fcdbb0f189>:0 --- End of inner exception stack trace --- at MvvmCross.Platform.IoC.MvxSimpleIoCContainer.IoCConstruct (System.Type type)
[0x0005b] in <4ddde23419c5494288c799fcdbb0f189>:0 at MvvmCross.Platform.Mvx.IocConstruct (System.Type t)
[0x00005] in <4ddde23419c5494288c799fcdbb0f189>:0 at MvvmCross.Core.ViewModels.MvxDefaultViewModelLocator.Load (System.Type viewModelType, MvvmCross.Core.ViewModels.IMvxBundle parameterValues, MvvmCross.Core.ViewModels.IMvxBundle savedState)
[0x00000] in <69bce0378e8e413982d3b552d7e387a8>:0 --- End of inner exception stack trace --- at MvvmCross.Core.ViewModels.MvxDefaultViewModelLocator.Load (System.Type viewModelType, MvvmCross.Core.ViewModels.IMvxBundle parameterValues, MvvmCross.Core.ViewModels.IMvxBundle savedState)
[0x00027] in <69bce0378e8e413982d3b552d7e387a8>:0 at MvvmCross.Core.ViewModels.MvxViewModelLoader.LoadViewModel (MvvmCross.Core.ViewModels.MvxViewModelRequest request, MvvmCross.Core.ViewModels.IMvxBundle savedState, MvvmCross.Core.ViewModels.IMvxViewModelLocator viewModelLocator)
[0x00015] in <69bce0378e8e413982d3b552d7e387a8>:0 --- End of inner exception stack trace --- at MvvmCross.Core.ViewModels.MvxViewModelLoader.LoadViewModel (MvvmCross.Core.ViewModels.MvxViewModelRequest request, MvvmCross.Core.ViewModels.IMvxBundle savedState, MvvmCross.Core.ViewModels.IMvxViewModelLocator viewModelLocator)
[0x00046] in <69bce0378e8e413982d3b552d7e387a8>:0 at MvvmCross.Core.ViewModels.MvxViewModelLoader.LoadViewModel (MvvmCross.Core.ViewModels.MvxViewModelRequest request, MvvmCross.Core.ViewModels.IMvxBundle savedState)
[0x00020] in <69bce0378e8e413982d3b552d7e387a8>:0 at MvvmCross.Droid.Views.MvxAndroidViewsContainer.ViewModelFromRequest (MvvmCross.Core.ViewModels.MvxViewModelRequest viewModelRequest, MvvmCross.Core.ViewModels.IMvxBundle savedState)
[0x00005] in :0 at MvvmCross.Droid.Views.MvxAndroidViewsContainer.CreateViewModelFromIntent (Android.Content.Intent intent, MvvmCross.Core.ViewModels.IMvxBundle savedState)
[0x00027] in :0 at MvvmCross.Droid.Views.MvxAndroidViewsContainer.Load (Android.Content.Intent intent, MvvmCross.Core.ViewModels.IMvxBundle savedState, System.Type viewModelTypeHint)
[0x00089] in :0 at MvvmCross.Droid.Views.MvxActivityViewExtensions.LoadViewModel (MvvmCross.Droid.Views.IMvxAndroidView androidView, MvvmCross.Core.ViewModels.IMvxBundle savedState)
[0x0006a] in :0 at MvvmCross.Droid.Views.MvxActivityViewExtensions+<>c__DisplayClass1_0.b__1 ()
[0x0000a] in :0 at MvvmCross.Core.Views.MvxViewExtensionMethods.OnViewCreate (MvvmCross.Core.Views.IMvxView view, System.Func`1[TResult] viewModelLoader)
[0x00012] in <69bce0378e8e413982d3b552d7e387a8>:0 at MvvmCross.Droid.Views.MvxActivityViewExtensions.OnViewCreate (MvvmCross.Droid.Views.IMvxAndroidView androidView, Android.OS.Bundle bundle)
[0x00062] in :0 at MvvmCross.Droid.Views.MvxActivityAdapter.EventSourceOnCreateCalled (System.Object sender, MvvmCross.Platform.Core.MvxValueEventArgs`1[T] eventArgs)
[0x0000c] in :0 at (wrapper delegate-invoke) System.EventHandler`1[MvvmCross.Platform.Core.MvxValueEventArgs`1[Android.OS.Bundle]]:invoke_void_object_TEventArgs (object,MvvmCross.Platform.Core.MvxValueEventArgs`1) at MvvmCross.Platform.Core.MvxDelegateExtensionMethods.Raise[T] (System.EventHandler`1[TEventArgs] eventHandler, System.Object sender, T value)
[0x0000b] in <4ddde23419c5494288c799fcdbb0f189>:0 at MvvmCross.Platform.Droid.Views.MvxEventSourceActivity.OnCreate (Android.OS.Bundle bundle)
[0x00014] in <4230cf00b647458f9b3e211590e6cc9d>:0 at Test.Droid.Views.BaseView`1[TViewModel].OnCreate (Android.OS.Bundle bundle)
[0x00000] in <0fa1f44ee2f748fe816e790571c2153b>:0 at Test.Droid.Views.MainMenuView.OnCreate (Android.OS.Bundle bundle)
[0x00000] in <0fa1f44ee2f748fe816e790571c2153b>:0 at Android.App.Activity.n_OnCreate_Landroid_os_Bundle_ (System.IntPtr jnienv, System.IntPtr native__this, System.IntPtr native_savedInstanceState)
[0x00011] in :0 at (wrapper dynamic-method) System.Object:e6d6ef29-3746-4c8e-b037-c64f6dfe49f0 (intptr,intptr,intptr)
This is a linking issue. You have some kind of DialogProvider, which uses the Android.Text.Html.FromHtml method, which seems to be stripped out.
You can add expressions to LinkerPleaseInclude.cs to prevent the linker from removing code or you can add [Preserve(AllMembers = true)] attribute on your DialogProvider class.
On Android I am getting this error Java.Lang.IllegalArgumentException:
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000b] in /Users/builder/data/lanes/2058/58099c53/source/mono/mcs/class/corlib/System.Runtime.ExceptionServices/ExceptionDispatchInfo.cs:61
at System.Runtime.CompilerServices.AsyncMethodBuilderCore.m__0 (object) [0x00000] in /Users/builder/data/lanes/2058/58099c53/source/mono/external/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:1006
at Android.App.SyncContext/c__AnonStorey0.<>m__0 () [0x00000] in /Users/builder/data/lanes/2058/58099c53/source/monodroid/src/Mono.Android/src/Android.App/SyncContext.cs:18
at Java.Lang.Thread/RunnableImplementor.Run () [0x0000b] in /Users/builder/data/lanes/2058/58099c53/source/monodroid/src/Mono.Android/src/Java.Lang/Thread.cs:36
at Java.Lang.IRunnableInvoker.n_Run (intptr,intptr) [0x00009] in /Users/builder/data/lanes/2058/58099c53/source/monodroid/src/Mono.Android/platforms/android-21/src/generated/Java.Lang.IRunnable.cs:71
at (wrapper dynamic-method) object.7dac782f-30e4-45cb-a248-e0c4c79fbcad (intptr,intptr)
--- End of managed exception stack trace --- java.lang.IllegalArgumentException at
android.media.MediaMetadataRetriever.setDataSource(MediaMetadataRetriever.java:169) at dalvik.system.NativeStart.run(Native Method)
using this code to retrive *.mp3 file duration:
public async Task<string> GetTrackDuration(string pathToFile)
{
MediaMetadataRetriever reader = new MediaMetadataRetriever();
await reader.SetDataSourceAsync (global::Android.App.Application.Context, Android.Net.Uri.Parse (pathToFile));
return reader.ExtractMetadata(MetadataKey.Duration).ToString();
}
where is the problem? I have tried all of the posible constructors
I have an installed WCF service on my computer. And I can successfully connect to this service from Console app on windows, but if i use the same code on android it doesn't work.
using System;
using System.ServiceModel;
using Android.App;
using Android.Widget;
using Android.OS;
namespace App1
{
[ServiceContract]
public interface ILogonService
{
[OperationContract]
string Logon(string appId);
}
[Activity(Label = "App1", MainLauncher = true, Icon = "#drawable/icon")]
public class MainActivity : Activity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.Main);
Button button = FindViewById<Button>(Resource.Id.MyButton);
button.Click += ButtonOnClick;
}
private void ButtonOnClick(object sender, EventArgs eventArgs)
{
var binding = new BasicHttpBinding(BasicHttpSecurityMode.TransportCredentialOnly);
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;
var endPointUri = new Uri(#"http://192.168.1.241/edo/Euphrates.svc/ILogonService-Basic");
var factory = new ChannelFactory<ILogonService>(binding, new EndpointAddress(endPointUri));
factory.Credentials.UserName.UserName = "test";
factory.Credentials.UserName.Password = "test";
ILogonService service = factory.CreateChannel();
Console.WriteLine(service.Logon("test"));
}
}
}
I am getting this error:
"System.Net.WebException: There was an error on processing web
request: Status code 401(Unauthorized): Unauthorized". 11-19
18:16:29.973 E/mono ( 1177): 11-19 18:16:29.973 E/mono ( 1177):
Unhandled Exception: 11-19 18:16:29.973 E/mono ( 1177):
System.Net.WebException: There was an error on processing web request:
Status code 401(Unauthorized): Unauthorized 11-19 18:16:29.973 E/mono
( 1177): at
System.ServiceModel.Channels.HttpRequestChannel+HttpChannelRequestAsyncResult.WaitEnd
() [0x00000] in :0 11-19 18:16:29.973 E/mono ( 1177): at
System.ServiceModel.Channels.HttpRequestChannel.EndRequest
(IAsyncResult result) [0x00000] in :0 11-19 18:16:29.973 E/mono (
1177): at System.ServiceModel.Channels.HttpRequestChannel.Request
(System.ServiceModel.Channels.Message message, TimeSpan timeout)
[0x00000] in :0 11-19 18:16:29.973 E/mono ( 1177): at
System.ServiceModel.MonoInternal.ClientRuntimeChannel.Request
(System.ServiceModel.Channels.Message msg, TimeSpan timeout) [0x00000]
in :0 11-19 18:16:29.973 E/mono ( 1177): at
System.ServiceModel.MonoInternal.ClientRuntimeChannel.Request
(System.ServiceModel.Description.OperationDescription od,
System.Object[] parameters) [0x00000] in :0 11-19 18:16:29.973 E/mono
( 1177): at
System.ServiceModel.MonoInternal.ClientRuntimeChannel.DoProcess
(System.Reflection.MethodBase method, System.String operationName,
System.Object[] parameters) [0x00000] in :0 11-19 18:16:29.973 E/mono
( 1177): at
System.ServiceModel.MonoInternal.ClientRuntimeChannel.Process
(System.Reflection.MethodBase method, System.String operationName,
System.Object[] parameters) [0x00000] in :0
How can I solve this problem? Any ideas?
Thanks