C# 错误:";Microsoft.WindowsAPICodePack.Shell.PropertySystem.PropertySystemException无法获取此属性的可写属性存储。”;
我已经创建了dotnet应用程序,它正在更新XLSX文件的元数据(例如“Title”属性) 我正在我的应用程序中使用C# 错误:";Microsoft.WindowsAPICodePack.Shell.PropertySystem.PropertySystemException无法获取此属性的可写属性存储。”;,c#,.net,xlsx,C#,.net,Xlsx,我已经创建了dotnet应用程序,它正在更新XLSX文件的元数据(例如“Title”属性) 我正在我的应用程序中使用Microsoft.WindowsAPICodePack.Shelllibrary…它完美地更新了开发环境中该文件的元数据 但在生产服务器上,该应用程序不工作 它给出的错误就像 Microsoft.WindowsAPICodePack.Shell.PropertySystem.PropertySystemException (0x80004005):无法获取此属性的可写属性存储 开
Microsoft.WindowsAPICodePack.Shell
library…它完美地更新了开发环境中该文件的元数据
但在生产服务器上,该应用程序不工作
它给出的错误就像
Microsoft.WindowsAPICodePack.Shell.PropertySystem.PropertySystemException
(0x80004005):无法获取此属性的可写属性存储
开发和生产环境正在安装相同的操作系统。Visual Studio和office安装在开发环境中。但不是在生产环境上
有人知道这件事吗 将以下NuGet包添加到项目中:
Microsoft.WindowsAPICodePack Shell
Microsoft.WindowsAPICodePack核心
Windows api代码包早就停止使用了。我怀疑这是因为他们很难支持那些难以诊断的程序员。与此类似,它对根本问题几乎没有指导意义。使用try/catch接受任何异常都很重要。它可能会失败,原因可能是文件格式不支持添加元数据,机器没有安装支持该文件格式的PropertyHandler组件,或者是因为您的应用程序没有对该文件的写入权限。最明显的原因是机器没有安装Office,这正是我们试图实现的。。我们不希望在读取和写入excel文件时依赖microsoft office。。。有没有人能找到解决这个错误的方法呢?似乎对我不起作用。。。我面临的错误日志如下所示。。。。。Microsoft.WindowsAPICodePack.Shell.PropertySystem.PropertySystemException(0x80004005):无法获取此属性的可写属性存储。-->System.Runtime.InteropServices.COMException(0x80004005):调用COM组件时返回错误HRESULT E_FAIL。在c:\projects\Windows API代码包1.1\source\WindowsAPICodePack中的Microsoft.WindowsAPICodePack.Shell.PropertySystem.ShellPropertyWriter..ctor(ShellObject父对象)中-
using Microsoft.WindowsAPICodePack.Shell;
using Microsoft.WindowsAPICodePack.Shell.PropertySystem;
string filePath = @"yourfilepath";
var file = ShellFile.FromFilePath(filePath);
// Read and Write:
string[] oldAuthors = file.Properties.System.Author.Value;
string oldTitle = file.Properties.System.Title.Value;
file.Properties.System.Author.Value = new string[] { "Author #1", "Author #2" };
file.Properties.System.Title.Value = "Example Title";
// Alternate way to Write:
ShellPropertyWriter propertyWriter = file.Properties.GetPropertyWriter();
propertyWriter.WriteProperty(SystemProperties.System.Author, new string[] { "Author" });
propertyWriter.Close();