Why am I getting 'Assembly '*.dll' must be strong signed in order to be marked as a prerequisite.'?

后端 未结 27 630
隐瞒了意图╮
隐瞒了意图╮ 2021-01-29 20:28

I\'m trying to compile my excel addin using C# 4.0, and started to get this problem when building my project in Visual Studio. It\'s important to tell you that I haven\'t had th

相关标签:
27条回答
  • 2021-01-29 21:13

    If you tried all the other answers in this question and you:

    • Have multiple projects in your solution
    • Have a project (Project A) that references another project (Project B), whose project references a NuGet package.
    • In Project A, you used Intellisense/ReSharper to bring in the reference to the NuGet package referenced in Project B (this can happen when a method in Project B returns a type provided by the NuGet package and that method is used in Project A)
    • updated the NuGet package via NuGet Package Manager (or CLI).

    ...you may have separate versions of the NuGet packages DLL in your projects' References, as the reference created by Intellisense/ReSharper will be a "normal" reference, and not a NuGet reference as expected, so the NuGet update process won't find or update it!

    To fix this, remove the reference in Project A, then use NuGet to install it, and make sure the NuGet packages in all projects are the same version. (as explain in this answer)


    Life Pro Tip:

    This issue can come up whenever ReSharper/Intellisense suggests to add a reference to your project. It can be much more deeply convoluted than the example above, with multiple interweaving projects and dependencies making it hard to track down. If the reference being suggested by ReSharper/Intellisense is actually from a NuGet package, use NuGet to install it.

    0 讨论(0)
  • 2021-01-29 21:13

    I encountered this problem after migrating an Excel Addin from packages.config to PackageReference. Seems to be related to this issue.

    The following works as a crude workaround if you're not using ClickOnce (it will omit all the dependency information from the .manifest file):

    1. Unload project, edit .csproj
    2. Find the section looking like this:

      <!-- Include additional build rules for an Office application add-in. -->
      <Import Project="$(VSToolsPath)\OfficeTools\Microsoft.VisualStudio.Tools.Office.targets" Condition="'$(VSToolsPath)' != ''" />
      
    3. Edit a renamed copy of the referenced .targets file (in my case, the file resolved to C:\Program Files (x86)\Microsoft Visual Studio\2017\Professional\MSBuild\Microsoft\VisualStudio\v15.0\OfficeTools\Microsoft.VisualStudio.Tools.Office.targets and I made a copy Microsoft.VisualStudio.Tools.Office_FIX.targets in the same folder - didn't check if it works from a different folder).

    4. Find the GenerateApplicationManifest element and change its attribute Dependencies="@(DependenciesForGam)" to Dependencies="".

    5. Change the section found in 2. to reference your edited .targets file instead.

    This will have to be repeated whenever the version of the .targets file shipped with VS is updated (or you won't get the updates), but I'm hoping it will be fixed soon...

    0 讨论(0)
  • 2021-01-29 21:14

    I had this in a solution w/ 6 projects. One of my projects was referring to the named assembly as a file reference. The others were all pointing to the project reference.

    I usually get a different error in these cases.

    My solution was to delete the named assembly anywhere it was referenced and add it back. Once I worked through the project, ths problem disappeared. Before doing this, I tried cleaning the solution as well as making sure none of the projects were signed.

    hope it helps someone...

    0 讨论(0)
提交回复
热议问题