Could not load file or assembly 'System.ComponentModel.Annotations, Version=4.1.0.0

前端 未结 9 1273
情书的邮戳
情书的邮戳 2020-12-01 09:13

I have a .NET Standard 1.4 class library that references the System.ComponentModel.Annotations (4.3.0) NuGet package.

I\'m then referencing this class library from a

相关标签:
9条回答
  • 2020-12-01 09:43

    I fixed this error by doing the Clean Solution command in Visual Studio 2019.

    0 讨论(0)
  • 2020-12-01 09:46

    I had similar problem but none of the above answers helped me. It turns out that solution is very easy, I've just run following command in Package Manager:

    Install-Package System.ComponentModel.Annotations -Version 4.1.0

    0 讨论(0)
  • 2020-12-01 09:46

    This usually happens when visual studio can't figure out the correct bindingRedirect.

    Most likely the cause it that the version of the nugget does not match the version of the produced library.

    To fix do this:

    1. From package manage console do:

      Get-Project –All | Add-BindingRedirect

      to regenerate assemblyBinding configuration at the config file

    2. If didn't fix it, then add manually the binding redirection:

      <dependentAssembly>
          <assemblyIdentity name="System.ComponentModel.Annotations"    publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
          <bindingRedirect oldVersion="0.0.0.0-X" newVersion="Y" />
      </dependentAssembly>
      

      where:

      1. X is the version that can't be load, from the error message
      2. Y is the version on your project references. To get it, select the library from the references node, and look for the version on property pane.
    0 讨论(0)
提交回复
热议问题