我们如何使用为商店打包的 .NET7 或 8 以及 WPF Core 访问 Windows.Storage?
举个例子,我们曾经这样做过:
Log.Logger = new LoggerConfiguration()
.MinimumLevel.Information()
.WriteTo.File(Path.Combine(ApplicationData.Current.LocalFolder.Path, "app.log")
.CreateLogger();
但是,ApplicationData.Current.LocalFolder.Path 现在抛出:
System.TypeInitializationException:
'The type initializer for 'WinRT.ActivationFactory`1' threw an exception.'
Inner Exception:
COMException: ClassFactory cannot supply requested class
仅供参考:
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>net7.0-windows10.0.22621.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UseWPF>true</UseWPF>
</PropertyGroup>
它曾经在 Windows 10 下工作,似乎找不到任何有关该主题的文档,有人知道吗?