You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

.NET MAUI iOS构建DevExpress控件触发TypeLoadException问题求助

问题描述

使用DevExpress的DXCalendar控件开发MAUI日历UI,Android平台运行正常,但iOS平台启动时抛出System.TypeLoadException,异常信息如下:

System.TypeLoadException: Could not resolve type with token 0100000e from typeref (expected class 'System.Resources.UltimateResourceFallbackLocation' in assembly 'netstandard, Version=2.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51')
  at at System.Reflection.CustomAttribute.GetCustomAttributesBase(ICustomAttributeProvider , Type , Boolean )
  at at System.Reflection.CustomAttribute.GetCustomAttributes(ICustomAttributeProvider , Type , Boolean )
  at at System.Reflection.RuntimeAssembly.GetCustomAttributes(Type , Boolean )
  at at Microsoft.Maui.Platform.ReflectionExtensions.GetCustomAttributesSafe(Assembly assembly, Type attrType)
  at at Microsoft.Maui.Controls.Internals.Registrar.RegisterAll(Assembly[] assemblies, Assembly defaultRendererAssembly, Type[] attrTypes, InitializationFlags flags, Action`1 viewRegistered, IFontRegistrar fontRegistrar)
  at at Microsoft.Maui.Controls.Internals.Registrar.RegisterAll(Type[] attrTypes, InitializationFlags flags, IFontRegistrar fontRegistrar)
  at at Microsoft.Maui.Controls.Internals.Registrar.RegisterAll(Type[] attrTypes, IFontRegistrar fontRegistrar)
  at at Microsoft.Maui.Controls.Compatibility.Forms.RegisterCompatRenderers(IMauiContext )
  at at Microsoft.Maui.Controls.Compatibility.Forms.SetupInit(IMauiContext , Nullable`1 )
  at at Microsoft.Maui.Controls.Compatibility.Forms.Init(IActivationState , Nullable`1 )
  at at Microsoft.Maui.Controls.Compatibility.Hosting.AppHostBuilderExtensions.<>c.<OnConfigureLifeCycle>b__1_1(IMauiContext )
  at at Microsoft.Maui.Platform.ApplicationExtensions.<>c__DisplayClass3_0.<CreatePlatformWindow>b__0(OnMauiContextCreated del)
  at at Microsoft.Maui.LifecycleEvents.LifecycleEventServiceExtensions.InvokeLifecycleEvents[OnMauiContextCreated](IServiceProvider services, Action`1 action)
  at at Microsoft.Maui.Platform.ApplicationExtensions.CreatePlatformWindow(IApplication application, UIWindowScene windowScene, NSDictionary[] states)
  at at Microsoft.Maui.Platform.ApplicationExtensions.CreatePlatformWindow(IUIApplicationDelegate platformApplication, IApplication application, UIApplication uiApplication, NSDictionary launchOptions)
  at at Microsoft.Maui.MauiUIApplicationDelegate.FinishedLaunching(UIApplication application, NSDictionary launchOptions)
  at at UIKit.UIApplication.UIApplicationMain(Int32 , String[] , IntPtr , IntPtr )
  at at UIKit.UIApplication.Main(String[] , Type , Type )
  at CalmanacMobileAPP.Program.Main(String[] args) in /Users/apple/Downloads/Vivek/Projects/MobileAPP/Platforms/iOS/Program.cs:13

已完成的配置:

  1. MauiProgram.cs中注册DevExpress:
public static MauiApp CreateMauiApp()
{
    var builder = MauiApp.CreateBuilder();
    builder
        .UseMauiApp<App>()
        .UseDevExpress()
        .UseMauiCommunityToolkit()                     
        .ConfigureFonts(fonts =>
        {
            fonts.AddFont("OpenSans-Regular.ttf", "OpenSansRegular");
            fonts.AddFont("OpenSans-Semibold.ttf", "OpenSansSemibold");
        })
        .RegisterAppServices()
        .RegisterAppRepository()
        .RegisterViewModels()
        .RegisterViews();
}
  1. XAML中使用DXCalendar控件:
<dxe:DXCalendar ActiveViewType="Month"  HeightRequest="400" Grid.Row="0" SelectedDate="{Binding SelectedDate}"
                BackgroundColor="{StaticResource AppWhite}"  x:Name="claender" CustomDayCellAppearance="CustomDayCellAppearance"                       
                VerticalOptions="StartAndExpand" ShowTrailingDays="True">
    <dxe:DXCalendar.HeaderAppearance>
         <dxe:CalendarHeaderAppearance HeaderTitleTextColor="{StaticResource AppBlack}"
                              HeaderSubtitleTextColor="DimGray"
                              BackgroundColor="{StaticResource AppWhite}"/>
    </dxe:DXCalendar.HeaderAppearance>
    <dxe:DXCalendar.DayCellAppearance>
             <dxe:CalendarDayCellAppearance FontAttributes="Bold"
                                TextColor="Black"
                               SelectedBackgroundColor="#f29285"
                               SelectedEllipseBackgroundColor="#f29281"
                               TodayEllipseBackgroundColor="#f29285"/>
    </dxe:DXCalendar.DayCellAppearance>
    
    <dxe:DXCalendar.DayOfWeekCellAppearance>
        <dxe:CalendarDayOfWeekCellAppearance FontAttributes="Bold" TextColor="Black" />
    </dxe:DXCalendar.DayOfWeekCellAppearance>         
</dxe:DXCalendar>
  1. 通过NuGet包管理器添加了DevExpress相关包。

异常原因

System.Resources.UltimateResourceFallbackLocation是仅.NET Framework存在的类型,.NET Standard 2.0和MAUI依赖的.NET 6+/iOS平台框架中并不包含该类型。出现此异常的核心原因是:

  • 项目引用的程序集(大概率是DevExpress相关包)中包含了对该.NET Framework专属类型的引用,导致iOS平台无法解析;
  • 通常是DevExpress MAUI包版本与项目目标框架不匹配,或是iOS项目的目标框架设置过低,引发了兼容性冲突。

解决方案

1. 检查并更新iOS项目目标框架

右键iOS项目 → 属性 → 应用 → 目标框架,确保选择的是.NET 6或更高版本(MAUI最低要求.NET 6,推荐使用.NET 7/.NET 8稳定版)。

2. 确认并更新DevExpress MAUI包版本

  • 打开NuGet包管理器,确保安装的是DevExpress.Maui.Editors(DXCalendar属于此包)的最新稳定版,且版本与项目的.NET版本兼容(例如.NET 8需使用支持.NET 8的DevExpress版本);
  • 移除任何旧的、针对.NET Framework的DevExpress兼容包,避免版本冲突。

3. 清理项目并重建

  • 右键解决方案 → 清理解决方案;
  • 手动删除所有项目的bin和obj文件夹;
  • 右键解决方案 → 重建解决方案。

4. 检查并移除冲突的第三方包

排查项目中是否存在仅支持.NET Framework的第三方包,将其替换为支持MAUI/.NET 6+的版本,或直接移除。

5. 更新MAUI SDK到最新稳定版

如果使用的是较旧的MAUI SDK,通过Visual Studio的"工具→选项→环境→预览功能"或.NET CLI更新到最新稳定版,确保iOS平台的运行时组件是最新的。


内容的提问来源于stack exchange,提问作者user16258378

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.14 19:43:08