I have a WebAPI project which had an old assembly reference to System.ComponentModel.DataAnnotations.dll
I am trying to add some logging and the nuget package for Microsoft.Extensions.Logginghas a dependency on System.ComponentModel.Annotations.dll which conflicts with the assembly reference.
After removing the assembly reference the project still compiles just fine, but at runtime I get an exception when I reach code with annotations:
Could not load file or assembly 'System.ComponentModel.Annotations,
Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or
one of its dependencies. The system cannot find the file specified.
I have tried installing the nuget package for System.ComponentModel.Annotations, but I still get the same error.
How do I replace the assembly reference to ComponentModel.DataAnnotations with the nuget package?
Related
I am adding a nuget package which has dependency of Microsoft.Extensions.Primitives (>= 6.0.0) to a Class Library project (.NETStandard 2.0).
This class library project should be added as reference to my service project which already has reference to Microsoft.Extensions.Primitives (3.1.11)
So while building my solution file with these 2 above projects, the target directory has Microsoft.Extensions.Primitives of version 6.0.0. due to this, getting below error,
System.TypeLoadException: Could not load type 'Microsoft.Extensions.Primitives.InplaceStringBuilder' from assembly 'Microsoft.Extensions.Primitives, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60'.
at Microsoft.Net.Http.Headers.DateTimeFormatter.ToRfc1123String(DateTimeOffset dateTime, Boolean quoted)
any solution to this issue?
Can I build my class library project to a separate folder and load the dependent assemblies from there? so it won't conflict with service project assemblies?
I am having an error when I want to run my program. The error states that it could not load file or assembly 'System.Runtime, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The located assembly's manifest definition does not match the assembly reference.
I have checked on my target framework and package reference which I am now using net5.0 framework for my project. But the version of System.Runtime seems to be net6.0 framework. I have checked on my System.Runtime that the version is 5.0.0.0. So obviously the version 6.0.0.0 is missing. Does anyone know how to change the version of System.Runtime to be 5.0.0.0?
Error Message
System Runtime Details
.csproj file
Okay, so i just delete my bin and obj folder and proceed to clean and rebuild my project and it works perfectly. Wasted two days for this.
Got the inspiration from this link.
Credit to Levi Fuller's comment
I've created project_A targeting .NET Standard 2.0 and made a nuget package from it. Its dependencies look as follow:
project_A dependencies
Then this nuget is being used in project_B which results in errors during build (but only on TFS), which are:
error CS0012: The type 'Object' is defined in an assembly that is not
referenced. You must add a reference to assembly 'System.Runtime,
Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'.
project_B dependencies
It looks like after deletion of project_A nuget reference in project_B the errors are gone. Adding System.Runtime as nuget to the project_B doesn't fix it.
Thanks in advice for any ideas.
So I created a local nuget server to serve our Telerik dlls.
Whenever I use the local dlls on my machine (Without nuget), everything works fine. But when I delete the two references and install them through nuget the build fails with the error:
Cannot resolve reference assemblies. please check the reference
assemblies. Could not load file or assembly 'System.Core,
Version=5.0.5.0, Culture=neutral' or one of its dependencies. The
located assembly's manifest definition does not match the assembly
reference. (Exception from HRESULT:0x80131040)
I have checked that the local telerik DLL is the same version as the one found in the nuget package.
Anyone have a clue?
PS: Silverlight project
I recently added the package LinqToExcel to my .net 4 WPF project and now when entering the designer I am presented with the following error:
System.IO.FileNotFoundException
Could not load file or assembly 'Castle.DynamicProxy2, Version=2.1.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc' or one of its dependencies. The system cannot find the file specified.
LinqToExcel only has one dependency - log4net, which it installed as part of the NuGet process. Both are referenced and set to Copy Local. I'm not sure where the reference to Castle is coming from or how to go about fixing it.
Does anyone have any suggestions?