This is in a Maui Embedded Project. Other Telerik Controls are working.
Xaml:
<telerik:RadComboBox AutomationId="staticItemsComboBox">
<telerik:RadComboBox.ItemsSource>
<x:Array Type="{x:Type x:String}">
<x:String>USA</x:String>
<x:String>Uganda</x:String>
<x:String>Ukraine</x:String>
<x:String>Canada</x:String>
<x:String>France</x:String>
<x:String>Italy</x:String>
<x:String>United Kingdom</x:String>
<x:String>China</x:String>
<x:String>Japan</x:String>
</x:Array>
</telerik:RadComboBox.ItemsSource>
</telerik:RadComboBox>
StackTrace:
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation.
---> System.TypeInitializationException: The type initializer for 'Telerik.Maui.Controls.RadComboBox' threw an exception.
---> System.TypeInitializationException: The type initializer for 'Telerik.Maui.Controls.ComboBoxConstants' threw an exception.
---> System.NullReferenceException: Object reference not set to an instance of an object.
at Telerik.Maui.Controls.ComboBoxConstants..cctor()
--- End of inner exception stack trace ---
at Telerik.Maui.Controls.RadComboBox..cctor()
--- End of inner exception stack trace ---
at System.Reflection.ConstructorInvoker.InterpretedInvoke(Object obj, Span`1 args, BindingFlags invokeAttr)
--- End of inner exception stack trace ---
at System.RuntimeType.CreateInstanceMono(Boolean nonPublic, Boolean wrapExceptions)
at System.RuntimeType.CreateInstanceDefaultCtor(Boolean publicOnly, Boolean wrapExceptions)
at System.Activator.CreateInstance(Type type, Boolean nonPublic, Boolean wrapExceptions)
at System.Activator.CreateInstance(Type type, Boolean nonPublic)
at System.Activator.CreateInstance(Type type)
at Microsoft.Maui.Controls.Xaml.CreateValuesVisitor.Visit(ElementNode node, INode parentNode) in D:\a\_work\1\s\src\Controls\src\Xaml\CreateValuesVisitor.cs:line 102
at Microsoft.Maui.Controls.Xaml.ElementNode.Accept(IXamlNodeVisitor visitor, INode parentNode) in D:\a\_work\1\s\src\Controls\src\Xaml\XamlNode.cs:line 159
at Microsoft.Maui.Controls.Xaml.ElementNode.Accept(IXamlNodeVisitor visitor, INode parentNode) in D:\a\_work\1\s\src\Controls\src\Xaml\XamlNode.cs:line 155
at Microsoft.Maui.Controls.Xaml.ElementNode.Accept(IXamlNodeVisitor visitor, INode parentNode) in D:\a\_work\1\s\src\Controls\src\Xaml\XamlNode.cs:line 155
at Microsoft.Maui.Controls.Xaml.RootNode.Accept(IXamlNodeVisitor visitor, INode parentNode) in D:\a\_work\1\s\src\Controls\src\Xaml\XamlNode.cs:line 212
at Microsoft.Maui.Controls.Xaml.XamlLoader.Visit(RootNode rootnode, HydrationContext visitorContext, Boolean useDesignProperties) in D:\a\_work\1\s\src\Controls\src\Xaml\XamlLoader.cs:line 207
at Microsoft.Maui.Controls.Xaml.XamlLoader.Load(Object view, String xaml, Assembly rootAssembly, Boolean useDesignProperties) in D:\a\_work\1\s\src\Controls\src\Xaml\XamlLoader.cs:line 78
at Microsoft.Maui.Controls.Xaml.XamlLoader.Load(Object view, String xaml, Boolean useDesignProperties) in D:\a\_work\1\s\src\Controls\src\Xaml\XamlLoader.cs:line 53
at Microsoft.Maui.Controls.Xaml.XamlLoader.Load(Object view, Type callingType) in D:\a\_work\1\s\src\Controls\src\Xaml\XamlLoader.cs:line 49
at Microsoft.Maui.Controls.Xaml.Extensions.LoadFromXaml[StopList](StopList view, Type callingType) in D:\a\_work\1\s\src\Controls\src\Xaml\ViewExtensions.cs:line 37
at TransportACE_Maui.Source.UI.StopList.InitializeComponent() in C:\apacheta_git\TransportACE_HME\TransportACE_Maui\Microsoft.Maui.Controls.SourceGen\Microsoft.Maui.Controls.SourceGen.CodeBehindGenerator\Source_Views_StopList.xaml.sg.cs:line 26
at TransportACE_Maui.Source.UI.StopList..ctor(StopListViewModel viewModel) in C:\apacheta_git\TransportACE_HME\TransportACE_Maui\Source\Views\StopList.xaml.cs:line 13
at System.Reflection.RuntimeConstructorInfo.Invoke(BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitConstructor(ConstructorCallSite constructorCallSite, RuntimeResolverContext context)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2[[Microsoft.Extensions.DependencyInjection.ServiceLookup.RuntimeResolverContext, Microsoft.Extensions.DependencyInjection, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60],[System.Object, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].VisitCallSiteMain(ServiceCallSite callSite, RuntimeResolverContext argument)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.VisitDisposeCache(ServiceCallSite transientCallSite, RuntimeResolverContext context)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteVisitor`2[[Microsoft.Extensions.DependencyInjection.ServiceLookup.RuntimeResolverContext, Microsoft.Extensions.DependencyInjection, Version=7.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60],[System.Object, System.Private.CoreLib, Version=7.0.0.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e]].VisitCallSite(ServiceCallSite callSite, RuntimeResolverContext argument)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteRuntimeResolver.Resolve(ServiceCallSite callSite, ServiceProviderEngineScope scope)
at Microsoft.Extensions.DependencyInjection.ServiceLookup.RuntimeServiceProviderEngine.<>c__DisplayClass4_0.<RealizeService>b__0(ServiceProviderEngineScope scope)
at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType, ServiceProviderEngineScope serviceProviderEngineScope)
at Microsoft.Extensions.DependencyInjection.ServiceProvider.GetService(Type serviceType)
at Microsoft.Maui.MauiContext.WrappedServiceProvider.GetService(Type serviceType) in D:\a\_work\1\s\src\Core\src\MauiContext.cs:line 68
at Microsoft.Extensions.DependencyInjection.ServiceProviderServiceExtensions.GetService[StopList](IServiceProvider provider)
at TransportACE.Droid.StopsListMaui.OnCreate(Bundle bundle) in C:\apacheta_git\TransportACE_HME\TransportACE_Maui\Platforms\Android\Source\UITasks\StopsListMaui.cs:line 199
Hello Jon,
Thank you for the XAML snippet and provided stack trace.
I made a sample project with the code snippet you sent. I noticed that you have not set the x: Name to the ComboBox control. Can you please add this to your project and see if the exception is thrown again?
I am sending you a link to the issue which might occur if the x: Name is not set: Getting a XamlC error when trying to use common xmlns only in XAML without x:Name.
I tried to reproduce it but on my side, the code is buildable and works as expected once the x:Name property is set. I tested it with Visual Studio 2022, NET 7 version, and Telerik Ui for Maui 5.1.0 version. Can you please share more information what is the setup on your side? In addition, I am sending you the project I made. Can you please modify it if I have missed something on my side?
Looking forward to your answer.
Hello Jon,
Please see the attached project in my previous reply. Could you please modify it so I can test the unwanted behavior on my side? With the current information, I can't reproduce the exception.
Looking forward to your reply.
Hello Jon,
Do let us know once you manage to isolate the issue. I will be happy to assist you.