Hi recently started to work my .net maui apps in NET - 8 on iOs, but i having a problem with telerik i can't even load any view with a telerik component, instead I got this error:
Excepción no controlada del tipo 'System.Exception' en Microsoft.iOS.dll: 'Could not create an native instance of the type 'TelerikUI.TKWeakReference': the native class hasn't been loaded.
It is possible to ignore this condition by setting ObjCRuntime.Class.ThrowOnInitFailure to false.'
<No se puede evaluar el seguimiento de la pila de excepciones>
I can't find any info related o similar cases, what can i do?
I don't have this problem in android it only happens in iOS, I'm using NET 8.0 and Telerik 6.5.0 version
Hi Rafael,
Indeed, we haven't been reported such an issue with building on iOS so far. Still, I researched around for similar errors, and it seems it can happen with any static iOS libraries when deployment is executed to IPhone from VS for Windows without pairing to Mac. Is that the same situation you have when experiencing the issue?
I am referring to this Maui issue: https://github.com/dotnet/maui/issues/10800
I look forward to your reply.
Hi Yana,
I am using visual studio code for mac on a mac and I run the application to an ios emulator, at first the application runs, it is not until I try to enter a screen where there are telerik components present this error occurs and the screen does not even load.
As for static libraries, I use some from UIKIT for a custom render shell class, to fix an error I have with the size of the icons in my nav bar. I'm sharing this code with you to see if it might have something to do with it.
using System; using Microsoft.Maui.Controls.Handlers.Compatibility; using Microsoft.Maui.Controls.Platform.Compatibility; using Microsoft.Maui.Platform; using UIKit; using CoreGraphics; using Microsoft.Maui.Controls; using static UIKit.UINavigationBar; namespace AppMobile.Platforms.iOS.Custom { public class CustomShellRenderer : ShellRenderer { protected override IShellTabBarAppearanceTracker CreateTabBarAppearanceTracker() { return new CustomShellTabBarAppearanceTracker(); } protected override IShellPageRendererTracker CreatePageRendererTracker() { return new CustomShellPageRendererTracker(this); } protected override IShellNavBarAppearanceTracker CreateNavBarAppearanceTracker() { return new NoLineAppearanceTracker(); } } public class CustomShellTabBarAppearanceTracker : ShellTabBarAppearanceTracker, IShellTabBarAppearanceTracker { public void Dispose() { //throw new NotImplementedException(); } public void ResetAppearance(UITabBarController controller) { //throw new NotImplementedException(); } public void SetAppearance(UITabBarController controller, ShellAppearance appearance) { base.SetAppearance(controller, appearance); var tabBar = controller.TabBar; var tabBarAppareance = new UITabBarAppearance(); if (App.Current.Resources.TryGetValue("lightBrown", out var lighBrown) && App.Current.Resources.TryGetValue("darkFontBrown", out var darkBrown)) { var backgroundColor = (Color)lighBrown; var foregroundColor = (Color)darkBrown; tabBarAppareance.ConfigureWithOpaqueBackground(); tabBarAppareance.BackgroundColor = backgroundColor.ToPlatform(); tabBarAppareance.ShadowColor = foregroundColor.ToPlatform(); tabBar.ScrollEdgeAppearance = tabBar.StandardAppearance = tabBarAppareance; } var items = controller.TabBar.Items; if (items == null) { return; } for (int i = 0; i < items.Length; i++) { if (items[i] == null) continue; else { UITabBarItem item_temp = items[i]; UIView view = item_temp.ValueForKey(new Foundation.NSString("view")) as UIView; UILabel label = view.Subviews[1] as UILabel; //label.Lines = 2; //label.LineBreakMode = UILineBreakMode.WordWrap; //label.TextAlignment = UITextAlignment.Center; } } } public void UpdateLayout(UITabBarController controller) { //throw new NotImplementedException(); foreach (var tabbarItem in controller.TabBar.Items) { var prevImage = tabbarItem.Image;//.Copy() as UIImage; var size = new CGSize(24, 24); UIGraphics.BeginImageContextWithOptions(size, false, 0); prevImage.Draw(new CGRect(new CGPoint(0, 0), size)); var resizedImage = UIGraphics.GetImageFromCurrentImageContext(); UIGraphics.EndImageContext(); tabbarItem.Image = resizedImage; } } } public class CustomShellPageRendererTracker : ShellPageRendererTracker { public CustomShellPageRendererTracker(IShellContext context) : base(context) { } // protected override void UpdateTitleView() // { // if (ViewController == null || ViewController.NavigationItem == null) // { // return; // } // var titleView = Shell.GetTitleView(Page); // if (titleView == null) // { // var view = ViewController.NavigationItem.TitleView; // ViewController.NavigationItem.TitleView = null; // view?.Dispose(); // } // else // { // var view = new CustomTitleViewContainer(titleView); // ViewController.NavigationItem.TitleView = view; // } // } } public class CustomTitleViewContainer : UIContainerView { public CustomTitleViewContainer(View view) : base(view) { TranslatesAutoresizingMaskIntoConstraints = false; } public override CGSize IntrinsicContentSize => UILayoutFittingExpandedSize; } public class NoLineAppearanceTracker : IShellNavBarAppearanceTracker { public void Dispose() { } public void ResetAppearance(UINavigationController controller) { } public void SetAppearance(UINavigationController controller, ShellAppearance appearance) { var backgroundColor = new Color(); bool backgroundColorExist = false; if(App.Current.Resources.TryGetValue("lightBrown", out var colorvalue)) { backgroundColor = (Color)colorvalue; backgroundColorExist = true; } var navBar = controller.NavigationBar; var navigationBarAppearance = new UIKit.UINavigationBarAppearance(); navigationBarAppearance.ConfigureWithOpaqueBackground(); navigationBarAppearance.ShadowColor = UIColor.Clear; navigationBarAppearance.BackgroundColor = backgroundColorExist ? backgroundColor.ToPlatform() : UIColor.Brown; // Set the background color you want on the Shell NavBar navBar.ScrollEdgeAppearance = navBar.StandardAppearance = navigationBarAppearance; } public void SetHasShadow(UINavigationController controller, bool hasShadow) { } public void UpdateLayout(UINavigationController controller) { } } }The error solved upgrading the Telerik Version to 7.0.0 i installed the version in a windows device and paired to a mac via visual studio i could run the app and ios and use the Telerik Components Without problem, now i'm going to install it in mac a try to run the app visual studio code for mac.
Update:
It worked in mac too :).
Note:
The steps for replicate the error are create and maui 8 app and then try to use the Telerik Components in this project with the 6.5.0 telerik version