Search the Community
Showing results for tags 'xamarin'.
-
Hi, I am developing an android app using Xamarin in visual studio. I am re-using code from my c# windows application that I know is working, but in android I am getting a null object exception that I am not able to trace. Anyone more than me that is using xamarin and android? The code is simple: // Developers are encouraged to create their own ILogger implementation var logger = new NullLogger(); // This describes the device capabilities var capabilities = new ClientCapabilities(); // If using the portable class library you'll need to supply your own IDevice implementation. var device = new Device { DeviceName = "MyDeviceName", DeviceId = "11" }; // If using the portable class library you'll need to supply your own ICryptographyProvider implementation. var cryptoProvider = new CryptographyProvider(); var client = new ApiClient(logger, "http://192.168.0.100:8096", "My client name", device, "11", cryptoProvider); try { var authResult = new MediaBrowser.Model.Users.AuthenticationResult(); authResult = await ApiClientHandler.GetApiClient().AuthenticateUserAsync("usernamexxx", "passxxx"); // Report capabilities after authentication await ApiClientHandler.GetApiClient().ReportCapabilities(capabilities); } catch(Exception e) { string x = e.ToString(); } Singleton to get the api client: (Embyclient derives from api client with a couple of extra methods... public static EmbyClient GetApiClient() { if (_apiClient == null) { var device = new Device { DeviceName = "asdf", DeviceId = "My Device Id" }; var logger = new NullLogger(); // If using the portable class library you'll need to supply your own ICryptographyProvider implementation. var cryptoProvider = new CryptographyProvider(); _apiClient = new EmbyClient(logger, "http://192.168.0.100:8096", "asdf", device, "asdf", cryptoProvider); } return _apiClient; } exception is thrown on this row: authResult = await ApiClientHandler.GetApiClient().AuthenticateUserAsync("usernamexxx", "passxxx"); And is working perfectly in my windows app. {System.NullReferenceException: Object reference not set to an instance of an object. at Emby.ApiClient.Net.HttpWebRequestFactory.Create (Emby.ApiClient.Net.HttpRequest options) [0x00070] in <adca890d653b4bfd8613ba04b19aa10a>:0 at Emby.ApiClient.Net.HttpWebRequestClient+<GetResponse>d__10.MoveNext () [0x0003b] in <adca890d653b4bfd8613ba04b19aa10a>:0 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <43dbbdc147f2482093d8409abb04c233>:0 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <43dbbdc147f2482093d8409abb04c233>:0 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <43dbbdc147f2482093d8409abb04c233>:0 at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in <43dbbdc147f2482093d8409abb04c233>:0 at Emby.ApiClient.Net.HttpWebRequestClient+<SendAsync>d__13.MoveNext () [0x00073] in <adca890d653b4bfd8613ba04b19aa10a>:0 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <43dbbdc147f2482093d8409abb04c233>:0 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <43dbbdc147f2482093d8409abb04c233>:0 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <43dbbdc147f2482093d8409abb04c233>:0 at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in <43dbbdc147f2482093d8409abb04c233>:0 at Emby.ApiClient.ApiClient+<SendAsync>d__30.MoveNext () [0x0009d] in <adca890d653b4bfd8613ba04b19aa10a>:0 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <43dbbdc147f2482093d8409abb04c233>:0 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <43dbbdc147f2482093d8409abb04c233>:0 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <43dbbdc147f2482093d8409abb04c233>:0 at System.Runtime.CompilerServices.ConfiguredTaskAwaitable`1+ConfiguredTaskAwaiter[TResult].GetResult () [0x00000] in <43dbbdc147f2482093d8409abb04c233>:0 at Emby.ApiClient.ApiClient+<PostAsync>d__94`1[T].MoveNext () [0x0010f] in <adca890d653b4bfd8613ba04b19aa10a>:0 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <43dbbdc147f2482093d8409abb04c233>:0 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <43dbbdc147f2482093d8409abb04c233>:0 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <43dbbdc147f2482093d8409abb04c233>:0 at System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () [0x00000] in <43dbbdc147f2482093d8409abb04c233>:0 at Emby.ApiClient.ApiClient+<AuthenticateUserAsync>d__89.MoveNext () [0x0012a] in <adca890d653b4bfd8613ba04b19aa10a>:0 --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess (System.Threading.Tasks.Task task) [0x0003e] in <43dbbdc147f2482093d8409abb04c233>:0 at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification (System.Threading.Tasks.Task task) [0x00028] in <43dbbdc147f2482093d8409abb04c233>:0 at System.Runtime.CompilerServices.TaskAwaiter.ValidateEnd (System.Threading.Tasks.Task task) [0x00008] in <43dbbdc147f2482093d8409abb04c233>:0 at System.Runtime.CompilerServices.TaskAwaiter`1[TResult].GetResult () [0x00000] in <43dbbdc147f2482093d8409abb04c233>:0 at EmbyManager.Fragments.FragmentSeenShows+<NewMethod>d__7.MoveNext () [0x000b9] in C:\Users\jorge\source\repos\EmbyManager\EmbyManager\Fragments\FragmentSeenShows.cs:145 }