1.原因 載入的時候沒有調取 AssemblyLoadContext.Default 2.解決方案: 在程式啟動的時候,手動調用 /// <summary> /// Interaction logic for App.xaml /// </summary> public partial class ...
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