Getting error using RadComboBox control

1 Answer 325 Views
ComboBox
Jon
Top achievements
Rank 1
Jon asked on 21 Mar 2023, 06:15 PM

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

Maria
Telerik team
commented on 22 Mar 2023, 01:26 PM

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.

 

Jon
Top achievements
Rank 1
commented on 22 Mar 2023, 02:17 PM

I get the same error after adding x:Name 
Maria
Telerik team
commented on 22 Mar 2023, 04:25 PM

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.

Jon
Top achievements
Rank 1
commented on 22 Mar 2023, 04:58 PM

Hi Maria.  I have a workaround now using the Maui Picker instead.  Have to finish up some other sprint work but once the sprint is over and I have time I will try to create a repro project for this issue and the other issue I reported with RadSegmentedControl. 
Maria
Telerik team
commented on 23 Mar 2023, 09:26 AM

Hello Jon,

Do let us know once you manage to isolate the issue. I will be happy to assist you.

Jon
Top achievements
Rank 1
commented on 30 Mar 2023, 06:04 PM | edited

Here is the sample application.  Just run on an android device.  You can set a breakpoint in MainActivity.cs line 57 and you will see the exception: jdunaway/RadComboBoxSample: An Example of RadComboBox error in a MAUI Embedding application (github.com)

1 Answer, 1 is accepted

Sort by
0
Maria
Telerik team
answered on 04 Apr 2023, 09:46 AM

Hello Jon,

Thank you for the isolated project.

I reproduced the exception on my side. I have logged an item on your behalf in our public feedback portal. I am sending you a link to the item: Null Reference exception when using Native embedding. You can subscribe to the item to track its progress and get notified by email for any status changes. I have updated your Telerik points as well.

Let me know if I can assist you further.

Regards,
Maria
Progress Telerik

Virtual Classroom, the free self-paced technical training that gets you up to speed with Telerik and Kendo UI products quickly just got a fresh new look + new and improved content including a brand new Blazor course! Check it out at https://learn.telerik.com/.

Pushpalatha
Top achievements
Rank 1
commented on 03 May 2023, 12:29 PM

Still the issue exists. The Telerik MAUI Combobox does not bind the values. It throws exception. Please notify once the control works. Thanks.
Didi
Telerik team
commented on 03 May 2023, 12:38 PM

Hi Pushpalatha,

The behavior happens when native embedding is used. We have this logged here: https://feedback.telerik.com/maui/1604076-null-reference-exception-when-using-native-embedding 
Press the follow button to track its progress. 

If you do not use native embedding approach the control works as expected. 

 

Tags
ComboBox
Asked by
Jon
Top achievements
Rank 1
Answers by
Maria
Telerik team
Share this question
or