- A+
所属分类:.NET技术
1.原因
加载的时候没有调取
AssemblyLoadContext.Default
2.解决方案:
在程序启动的时候,手动调用
/// <summary> /// Interaction logic for App.xaml /// </summary> public partial class App : Application { protected override void OnStartup(StartupEventArgs e) { //SetCultureInfo(); LoadSatelliteAssemblies(); base.OnStartup(e); } /// <summary> /// 设置语言/本地化 /// </summary> private void SetCultureInfo() { // Create a new object, representing the German culture. CultureInfo culture = CultureInfo.CreateSpecificCulture("zh-CN"); // The following line provides localization for the application's user interface. Thread.CurrentThread.CurrentUICulture = culture; // The following line provides localization for data formats. Thread.CurrentThread.CurrentCulture = culture; // Set this culture as the default culture for all threads in this application. CultureInfo.DefaultThreadCurrentCulture = culture; CultureInfo.DefaultThreadCurrentUICulture = culture; } /// <summary> /// 加载程序集上下文,手动调用来查找卫星程序集 /// </summary> private void LoadSatelliteAssemblies() { //加载程序集上下文,必须 var loadContext = AssemblyLoadContext.Default; //var arr = loadContext.Assemblies; } }
参考:
https://docs.microsoft.com/zh-cn/dotnet/core/dependency-loading/loading-resources