【问题标题】:Exception reading manifest from file. Microsoft Word Add-in VSTO从文件中读取清单时出现异常。 Microsoft Word 加载项 VSTO
【发布时间】:2020-01-29 03:01:33
【问题描述】:

我正在尝试创建一个 Microsoft Word 加载项,该加载项将在每次保存 Word 文档(自动保存或手动保存)时添加并提交到 git 存储库。当我在 Visual Studio(调试模式)中运行程序时,我已经能够获得我想要的功能。当我发布并安装加载项以便它在 Word 启动时运行时,我收到以下错误。

现在,当我尝试添加 LibGit2Sharp NuGet 包时,在 Visual Studio 中以调试模式运行时会出现以下错误:

以及以下错误详情:

Name: 
From: file:///C:/Users/short/OneDrive for Business/SCHOOL/JP/EZGit/EZGit/MicrosoftWordAddIn/bin/Debug/MicrosoftWordAddIn.vsto

************** Exception Text **************
System.Deployment.Application.InvalidDeploymentException: Exception reading manifest from file:///C:/Users/short/OneDrive%20for%20Business/SCHOOL/JP/EZGit/EZGit/MicrosoftWordAddIn/bin/Debug/MicrosoftWordAddIn.dll.manifest: the manifest may not be valid or the file could not be opened. ---> System.Deployment.Application.InvalidDeploymentException: Application manifest is not semantically valid. ---> System.Deployment.Application.InvalidDeploymentException: File element lib\fedora-x64\native\..\libgit2-106a5f2.so must have a relative path.
   at System.Deployment.Application.Manifest.AssemblyManifest.ValidateFile(File f)
   at System.Deployment.Application.Manifest.AssemblyManifest.ValidateSemanticsForApplicationRole()
   --- End of inner exception stack trace ---
   at System.Deployment.Application.Manifest.AssemblyManifest.ValidateSemanticsForApplicationRole()
   at System.Deployment.Application.ManifestReader.FromDocument(String localPath, ManifestType manifestType, Uri sourceUri)
   --- End of inner exception stack trace ---
   at Microsoft.VisualStudio.Tools.Applications.Deployment.ClickOnceAddInDeploymentManager.GetManifests(TimeSpan timeout)
   at Microsoft.VisualStudio.Tools.Applications.Deployment.ClickOnceAddInDeploymentManager.InstallAddIn() 

我认为发布的解决方案需要这些包,但在没有它们的情况下可以在 Visual Studio 中工作。我安装它们以查看然后从 Visual Studio 中运行会导致错误。

我已尝试更改 .csproj 文件以添加以下内容

<Target Name="EnsureNetstandardFilesAreIncludedInClickOnce" BeforeTargets="_DeploymentComputeClickOnceManifestInfo">
    <Message Text="Adding netstandard files to ClickOnce" />
    <ItemGroup>
      <PublishFile Include="@(_NETStandardLibraryNETFrameworkLib->'%(FileName)')" KeepMetadata="None">
        <PublishState>Include</PublishState>
        <FileType>Assembly</FileType>
      </PublishFile>
    </ItemGroup>
    <!-- Consider using ReferenceCopyLocalPaths instead, if we are missing files -->
    <Message Text="Adding nuget files to ClickOnce" />
    <ItemGroup>
      <PublishFile Include="@(ReferencePath->'%(FileName)')" Condition=" '%(ReferencePath.NuGetSourceType)' == 'Package' and '%(ReferencePath.NuGetIsFrameworkReference)' != 'true'" KeepMetadata="None">
        <PublishState>Include</PublishState>
        <FileType>Assembly</FileType>
      </PublishFile>
    </ItemGroup>
    <Message Text="Adding Private True references to ClickOnce" />
    <ItemGroup>
      <PublishFile Include="@(ReferencePath->'%(FileName)')" Condition="'%(ReferencePath.Private)' == 'True'" KeepMetadata="None">
        <PublishState>Include</PublishState>
        <FileType>Assembly</FileType>
      </PublishFile>
    </ItemGroup>
  </Target>

【问题讨论】:

  • 根据站点规则,所有相关信息(例如代码和错误消息)都必须是纯文本,包含在问题本身中。请不要将这些东西作为图片提供。图片通常难以阅读,内容无法复制/粘贴以进行测试或研究。
  • 有了图片,我无法以任何其他方式得到错误,并且不允许我复制和粘贴。第二个错误是我的错,我想既然有一个超长的行,把它放在一个代码框中会更容易阅读。
  • 我已将说明和图片合并到问题中。关于图片中错误信息的观察表明:第一个是不可读的。如果可以复制/粘贴可读的错误消息以便对其进行研究,那么可以帮助您的人更有可能这样做。您要求专业人员利用他们自己的时间来帮助您 - 花时间写出信息符合您自己的利益...
  • 感谢您的帮助。我不熟悉在这里发帖的正确方法。

标签: c# visual-studio ms-word vsto libgit2sharp


【解决方案1】:

我也遇到了这个问题,并通过删除顶部 csproj 文件中的 import 语句解决了这个问题。在 ItemGroup 部分中仍然引用了 lib2git 库

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-04-07
    • 1970-01-01
    相关资源
    最近更新 更多