I created a ToolbaItems in a ContentPage that is a ShellContent from FlyoutItem - I am using ShellApp.
<ContentPage.ToolbarItems>
<ToolbarItem
x:Name="xicon"
Clicked=""
IconImageSource="{local1:ImageResource MobileApp.Resources.Images.x.png}"
Text="Saw X" />
<ToolbarItem
x:Name="yicon"
Clicked=""
IconImageSource="{local1:ImageResource MobileApp.Resources.Images.y.png}"
Text="Saw Y" />
<ToolbarItem
x:Name="zicon"
Clicked=""
IconImageSource="{local1:ImageResource MobileApp.Resources.Images.z.png}"
Text="Saw Z" />
</ContentPage.ToolbarItems>
In Android it works well, but in iOS I got an error:
Message "Cannot access a disposed object.\n
Object name: 'PrimaryToolbarItem'." string
$exception {System.ObjectDisposedException: Cannot access a disposed object.
Object name: 'PrimaryToolbarItem'.
at Foundation.NSObject.get_SuperHandle () [0x00012] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/Foundation/NSObject2.cs:469
at UIKit.UIBarButtonItem.set_Image (UIKit.UIImage value) [0x0002b] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/build/ios/native/UIKit/UIBarButtonItem.g.cs:827
at Xamarin.Forms.Platform.iOS.ToolbarItemExtensions+PrimaryToolbarItem.UpdateIconAndStyle () [0x00031] in D:\a\1\s\Xamarin.Forms.Platform.iOS\Extensions\ToolbarItemExtensions.cs:84
at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__7_0 (System.Object state) [0x00000] in /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:1021
at Foundation.NSAsyncSynchronizationContextDispatcher.Apply () [0x00000] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/Foundation/NSAction.cs:178
--- End of stack trace from previous location where exception was thrown ---
at (wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:86
at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x0000e] in /Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:65
at Toretto.MobileApp.iOS.Application.Main (System.String[] args) [0x00001] in C:\Projects\Toretto\Toretto.MobileApp\src\Toretto.MobileApp\Toretto.MobileApp.iOS\Main.cs:17 } System.ObjectDisposedException
If I remove theses items in the constructor of the ContentPage it does not crash, I tried to use only Text, in Android I am using icon and works...
public HomePage()
{
InitializeComponent();
if (DeviceInfo.Platform == DevicePlatform.iOS)
{
this.ToolbarItems.Clear();
}
}
Is this a bug? In github I saw few issue about toolbar.
Yes, it is just the case. It is a known issue, and xamarin development team have added this to To do in xamarin form v5.0.1.
You can follow it up here:https://github.com/xamarin/Xamarin.Forms/issues/6387.
We are sorry for the inconvenience.And thanks for your support for xamarin.
Related
SIGABRT: Cannot access a disposed object. Object name: 'SKGLView'.
We are using SKGLView in MainPage, sometimes back from another view, this error will show and app crash. I have no idea, and here is the log from App Center.
NSObject.get_SuperHandle ()
/Users/builder/azdo/_work/1/s/xamarin-macios/src/Foundation/NSObject2.cs:471
GLKView.Display ()
/Users/builder/azdo/_work/1/s/xamarin-macios/src/build/ios/native/GLKit/GLKView.g.cs:152
SKGLViewRenderer+<>c__DisplayClass4_0.b__1 ()
NSAsyncActionDispatcher.Apply ()
/Users/builder/azdo/_work/1/s/xamarin-macios/src/Foundation/NSAction.cs:152
(wrapper managed-to-native)
UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
UIApplication.Main (System.String[] args, System.IntPtr principal,
System.IntPtr delegate)
/Users/builder/azdo/_work/1/s/xamarin-macios/src/UIKit/UIApplication.cs:86
Application.Main (System.String[] args)
Finally, we solve it just by setting HasRenderLoop property for SKGLView using code, not in Xaml.
Reference link: https://github.com/mono/SkiaSharp/issues/870
I'm developing a mobile app with xamarin.forms, this app make a bluetooth connection to the CITIZEN printer. The printer has a plugin for xamarin.forms. This plugin is imported into the project; but when I try connect the printer from the application, it returns the following error:
Excepcion: Didn't find class "com.citizen.jpos.printer.CPCLPrinter" on path: DexPathList[[zip file "/data/app/com.companyname.facturaimpresion2.x_0-1/base.apk"],nativeLibraryDirectories=[/data/app/com.companyname.facturaimpresion2.x_0-1/lib/arm, /vendor/lib, /system/lib]]. StackTrace: at Java.Interop.JniEnvironment+Types.FindClass (System.String classname) [0x00129] in <bf671abdfa384ce99d758b134b9dd5bf>:0
at Java.Interop.JniType..ctor (System.String classname) [0x00006] in <bf671abdfa384ce99d758b134b9dd5bf>:0
at Java.Interop.JniType.GetCachedJniType (Java.Interop.JniType& cachedType, System.String classname) [0x00018] in <bf671abdfa384ce99d758b134b9dd5bf>:0
at Java.Interop.JniPeerMembers.get_JniPeerType () [0x0000c] in <bf671abdfa384ce99d758b134b9dd5bf>:0
at Java.Interop.JniPeerMembers+JniInstanceMethods.get_JniPeerType () [0x00014] in <bf671abdfa384ce99d758b134b9dd5bf>:0
at Java.Interop.JniPeerMembers+JniInstanceMethods.StartCreateInstance (System.String constructorSignature, System.Type declaringType, Java.Interop.JniArgumentValue* parameters) [0x0003f] in <bf671abdfa384ce99d758b134b9dd5bf>:0
at Com.Citizen.Jpos.Printer.CPCLPrinter..ctor () [0x00034] in <e141e43239ef42c4af494152c936c094>:0
at Plugin.CitizenXamarinSDK.CitizenXamarinCPCLImplementation.connect (System.String macAddress) [0x0009b] in <1427ae75e5b64afe9c92e8161f8405b8>:0
at facturaImpresion2._0.MainPage.OnConnectableDeviceSelection (System.Object sender, Xamarin.Forms.SelectedItemChangedEventArgs e) [0x00119] in C:\Users\segador\source\repos\FacturaImpresion\facturaImpresion2.0\facturaImpresion2.0\MainPage.xaml.cs:537
--- End of managed Java.Lang.ClassNotFoundException stack trace ---
java.lang.ClassNotFoundException: Didn't find class "com.citizen.jpos.printer.CPCLPrinter" on path: DexPathList[[zip file "/data/app/com.companyname.facturaimpresion2.x_0-1/base.apk"],nativeLibraryDirectories=[/data/app/com.companyname.facturaimpresion2.x_0-1/lib/arm, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
at crc643f46942d9dd1fff9.CellAdapter.n_onItemClick(Native Method)
at crc643f46942d9dd1fff9.CellAdapter.onItemClick(CellAdapter.java:89)
at android.widget.AdapterView.performItemClick(AdapterView.java:305)
at android.widget.AbsListView.performItemClick(AbsListView.java:1185)
at android.widget.AbsListView$PerformClick.run(AbsListView.java:3222)
at android.widget.AbsListView$3.run(AbsListView.java:4138)
at android.os.Handler.handleCallback(Handler.java:815)
at android.os.Handler.dispatchMessage(Handler.java:104)
at android.os.Looper.loop(Looper.java:194)
at android.app.ActivityThread.main(ActivityThread.java:5576)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:955)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:750)
Suppressed: java.lang.ClassNotFoundException: com.citizen.jpos.printer.CPCLPrinter
at java.lang.Class.classForName(Native Method)
at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
... 15 more
Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
I am using Sqlite in a Xamarin Forms Portable project and I successfully run my application on iOS and UWP. On Android, I can run my application on a Android 6.0 emulator but in Android Oreo although app is installed, it crashes on startup. I am facing the following issue.
Issue:
android.runtime.JavaProxyThrowable: at (wrapper managed-to-native)
SQLite.Net.Platform.XamarinAndroid.SQLiteApiAndroidInternal:sqlite3_open_v2
(byte[],intptr&,int,intptr) at
SQLite.Net.Platform.XamarinAndroid.SQLiteApiAndroid.Open
(System.Byte[] filename, SQLite.Net.Interop.IDbHandle& db,
System.Int32 flags, System.IntPtr zvfs) [0x00000] in
<8dbf6ff85082469fb9d4dfaa9eae6b69>:0 at
SQLite.Net.SQLiteConnection..ctor (SQLite.Net.Interop.ISQLitePlatform
sqlitePlatform, System.String databasePath,
SQLite.Net.Interop.SQLiteOpenFlags openFlags, System.Boolean
storeDateTimeAsTicks, SQLite.Net.IBlobSerializer serializer,
System.Collections.Generic.IDictionary2[TKey,TValue] tableMappings,
System.Collections.Generic.IDictionary2[TKey,TValue]
extraTypeMappings, SQLite.Net.IContractResolver resolver) [0x000a2] in
<8f2bb39aeff94a30a8628064be9c7efe>:0 at
SQLite.Net.SQLiteConnectionWithLock..ctor
(SQLite.Net.Interop.ISQLitePlatform sqlitePlatform,
SQLite.Net.SQLiteConnectionString connectionString,
System.Collections.Generic.IDictionary2[TKey,TValue] tableMappings,
System.Collections.Generic.IDictionary2[TKey,TValue]
extraTypeMappings) [0x0002e] in <8f2bb39aeff94a30a8628064be9c7efe>:0
at project.Models.Database+<>c__DisplayClass1_0.<.ctor>b__0 ()
[0x0001d] in <7df232f34ab8474d9153e3809af4eda8>:0 at
SQLite.Net.Async.SQLiteAsyncConnection.GetConnection () [0x00000] in
<563d605f9f014eeeb32fd4a27b4d142e>:0 at
SQLite.Net.Async.SQLiteAsyncConnection+<>c__DisplayClass11_0.b__0
() [0x00006] in <563d605f9f014eeeb32fd4a27b4d142e>:0 at
System.Threading.Tasks.Task`1[TResult].InnerInvoke () [0x0000f] in
:0 at
System.Threading.Tasks.Task.Execute () [0x00010] in
:0 at
mono.java.lang.RunnableImplementor.n_run (Native Method) at
mono.java.lang.RunnableImplementor.run (RunnableImplementor.java:30)
at android.os.Handler.handleCallback (Handler.java:789) at
android.os.Handler.dispatchMessage (Handler.java:98) at
android.os.Looper.loop (Looper.java:164) at
android.app.ActivityThread.main (ActivityThread.java:6541) at
java.lang.reflect.Method.invoke (Native Method) at
com.android.internal.os.Zygote$MethodAndArgsCaller.run
(Zygote.java:240) at com.android.internal.os.ZygoteInit.main
(ZygoteInit.java:767)
In order to create the connection:
public Database(string databaseName)
{
var pathToDatabaseFile = DependencyService.Get<Interfaces.ISQLite>().GetLocalPathToFile(databaseName);
var platform = DependencyService.Get<Interfaces.IPlatformProvider>().GetPlatform();
_connection = new SQLiteAsyncConnection(() =>
new SQLiteConnectionWithLock(platform, new SQLiteConnectionString(pathToDatabaseFile, false)));
_connection.CreateTableAsync<SqlitePage>().Wait();
}
In every project GetPlatform and GetLocalPathToFile are implemented:
return new SQLitePlatformAndroid();
and
return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), fileName);
The packages I use for Sqlite are:
SQLite.Net.Async-PCL
SQLite.Net.Core-PCL
SQLite.Net-PCL
Any ideas?
You should change to sqlite-net-pcl, since Android 6+, some permission have changed.
https://www.nuget.org/packages/sqlite-net-pcl/
I switched to this PCL, and everything works like a charm.
I have installed realm in a Xamarin app and when I try to use an object (count, write, etc) it gives me a System.EntryPointNotFoundException.
Below code:
_realm = Realm.GetInstance();
_realm.Write(() =>
{
var myConfig = _realm.CreateObject<Config>();
myConfig.Email = "";
myConfig.User = "";
});
System.EntryPointNotFoundException: shared_realm_begin_transaction
at at (wrapper managed-to-native) Realms.NativeSharedRealm:begin_transaction (Realms.SharedRealmHandle)
at Realms.Transaction..ctor (Realms.SharedRealmHandle sharedRealmHandle) [0x0000d] in :0
at Realms.Realm.BeginWrite () [0x00000] in :0
at Realms.Realm.Write (System.Action action) [0x00000] in :0
at rasoApp.ConfigViewModel..ctor () [0x00025] in /Users/luis/Projects/rasoApp/rasoApp/viewModels/ConfigViewModel.cs:22
at rasoApp.ConfigPage.SetBinding (Xamarin.Forms.BindableProperty targetProperty, Xamarin.Forms.BindingBase binding) [0x0000e] in /Users/luis/Projects/rasoApp/rasoApp/views/ConfigPage.xaml.cs:13
at rasoApp.HomePage.btnOpenConfig (System.Object sender, System.EventArgs e) [0x00007] in /Users/luis/Projects/rasoApp/rasoApp/views/HomePage.xaml.cs:18
at Xamarin.Forms.Button.Xamarin.Forms.IButtonController.SendClicked () [0x00020] in :0
at Xamarin.Forms.Platform.iOS.ButtonRenderer.OnButtonTouchUpInside (System.Object sender, System.EventArgs eventArgs) [0x0000e] in :0
at UIKit.UIControlEventProxy.Activated () [0x00007] in /Users/builder/data/lanes/3412/3cf8aaed/source/maccore/src/UIKit/UIControl.cs:38
at at (wrapper managed-to-native) UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
at UIKit.UIApplication.Main (System.String[] args, IntPtr principal, IntPtr delegate) [0x00005] in /Users/builder/data/lanes/3412/3cf8aaed/source/maccore/src/UIKit/UIApplication.cs:79
at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00038] in /Users/builder/data/lanes/3412/3cf8aaed/source/maccore/src/UIKit/UIApplication.cs:63
at rasoApp.iOS.Application.Main (System.String[] args) [0x00008] in /Users/luis/Projects/rasoApp/iOS/Main.cs:17
Congratulations on an interesting problem!
I have seen a similar error but only in recent work I was doing refining code generation, when I generated bad IL code. We have no previous issues recorded nor any discussions of EntryPointNotFoundException messages that I can find.
If you try building one of our examples from the Realm source download, such as QuickJournal does that work?
If you can send a full project demonstrating the problem to help#realm.io that is probably the fastest way to work out what is happening.
Update 2016-07-11
Looking at another SO question made me think of a few more things to try:
Does this happen on all platforms?
- Do you have Full Linking enabled in Xamarin studio?
Earlier Suggestions
Does your app have a PCL containing that logic?
Did you also install the Realm NuGet into the main application (IOS or Android) projects? That is a necessary step. The main Realm libraries are only included with the platform-specific dlls which NuGet adds to IOS or Android projects.
Trying to read data from Azure TableStorage in MVC 6 application on Mac.
It works on PC, but when on Mac it used to give this error:
TypeLoadException: Could not load type 'Microsoft.WindowsAzure.Storage.Core.Executor.RESTCommand`1[Microsoft.WindowsAzure.Storage.Table.TableResult]' from assembly 'Microsoft.WindowsAzure.Storage, Version=4.3.2.0, Culture=neutral, PublicKeyToken=null'.
Microsoft.WindowsAzure.Storage.Table.TableOperation.ExecuteAsync (Microsoft.WindowsAzure.Storage.Table.CloudTableClient client, System.String tableName, Microsoft.WindowsAzure.Storage.Table.TableRequestOptions requestOptions, Microsoft.WindowsAzure.Storage.OperationContext operationContext, CancellationToken cancellationToken) [0x00000] in <filename unknown>, line 0Stack Query Cookies Headers Environment
TypeLoadException: Could not load type 'Microsoft.WindowsAzure.Storage.Core.Executor.RESTCommand`1[Microsoft.WindowsAzure.Storage.Table.TableResult]' from assembly 'Microsoft.WindowsAzure.Storage, Version=4.3.2.0, Culture=neutral, PublicKeyToken=null'.
Microsoft.WindowsAzure.Storage.Table.TableOperation.ExecuteAsync (Microsoft.WindowsAzure.Storage.Table.CloudTableClient client, System.String tableName, Microsoft.WindowsAzure.Storage.Table.TableRequestOptions requestOptions, Microsoft.WindowsAzure.Storage.OperationContext operationContext, CancellationToken cancellationToken) [0x00000] in <filename unknown>
Microsoft.WindowsAzure.Storage.Table.CloudTableClient.ExecuteAsync (System.String tableName, Microsoft.WindowsAzure.Storage.Table.TableOperation operation, Microsoft.WindowsAzure.Storage.Table.TableRequestOptions requestOptions, Microsoft.WindowsAzure.Storage.OperationContext operationContext, CancellationToken cancellationToken) [0x00000] in <filename unknown>
Microsoft.WindowsAzure.Storage.Table.CloudTable+<>c__DisplayClass4+<<ExistsAsync>b__5>d__0.MoveNext () [0x00000] in <filename unknown>
--- End of stack trace from previous location where exception was thrown ---
System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x00000] in <filename unknown>
System.Runtime.CompilerServices.TaskAwaiter`1[System.Boolean].GetResult () [0x00000] in <filename unknown>
After following this discussion and installing System.Net.Http package using kpm I started to get a new error:
An unhandled exception occurred while processing the request.NullReferenceException: Object reference not set to an instance of an object
Microsoft.WindowsAzure.Storage.Shared.Protocol.HttpClientFactory.BuildHttpClient[TableResult] (Microsoft.WindowsAzure.Storage.Core.Executor.RESTCommand`1 cmd, System.Net.Http.HttpMessageHandler handler, Boolean useVersionHeader, Microsoft.WindowsAzure.Storage.OperationContext operationContext) [0x00000] in <filename unknown>, line 0
Note:
I had the System.Net.Http package installed in "aspnetcore50": { "dependencies": { ... } }, but it seems like it had to be installed in the common dependencies
Any idea why that might happen and how to fix it?
You cannot use Azure Storage .NET client under aspnetcore50, it's not available for this runtime. You need to pull it under aspnet50 (dnx451 now).