Dll issue in Aspnet Core - c#

I am getting System.Web.Http error while I am converting mvc5 application to aspnet core.
I am using class library in an existing project and also not using directly this .dll in class library.
error- Could not load file or assembly 'System.Web.Http,
Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35' or
one of its dependencies. The system cannot find the file specified.

Try reinstalling the NuGet package
From the package manager console, type:
Update-Package Microsoft.AspNet.WebApi.Core -reinstall

Related

Could not load type 'Microsoft.Extensions.Primitives.InplaceStringBuilder' from assembly 'Microsoft.Extensions.Primitives

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?

System.Text.Json 6.0.2 Serialize error - trying to load System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1

We are using C# .Net Framework 4.7.2, JsonSerializer in System.Text.Json Version 6.0.2. Solution builds fine. We get a runtime error when Serializing:
Could not load file or assembly 'System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference.
I confirmed that System.Runtime.CompilerServices.Unsafe Assembly Version 6.0.0 isinstalled as part of the NuGet package.
And that App.config contains assembly redirect lines pointing to installed Version:
name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral"
bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0"
Appreciate any help on how to resolve this - why is System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1 needed at Runtime. Thanks!
I had a similar error with Visual Studio 2022 Version 17.1.1 with a new .Net 4.8 WinForms application.
After some hints elsewhere, I opened the NuGet package manger for the solution.
Tools/NuGet Package Manager/Manage NuGet Packages for the Solution...
From there I searched for and added this package to the project that used JsonSerializer.Serialize().
System.Runtime.CompilerServices.Unsafe (V6.0.0)
To be clear this was not a listed installed packaged in the NuGet manager previously.
The runtime exception error changed to:
System.IO.FileNotFoundException HResult=0x80070002 Message=Could not load file or assembly 'System.Threading.Tasks.Extensions, Version=4.2.0.1, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The system cannot find the file specified. Source=System.Text.Json
So I then searched for and added to the same project:
System.Threading.Tasks.Extensions (V4.5.4)
Again this was not a listed installed package in the NuGet manager before this install.
So far everything continues to work. I did not have to add these packages to the project that defined the class being serialized. Just the one that did the serialization.

Install Microsoft.SqlServer.Types in GAC

How do I install Microsoft.SqlServer.Types assembly in GAC (C:\Windows\assembly\GAC_MSIL). It is missing.
I am getting error after running rdlc report. it is MVC based application-
Could not load file or assembly 'Microsoft.SqlServer.Types,
Version=12.0.0.0, Culture=neutral, PublicKeyToken=token' or one of its
dependencies.
It seems application is looking Microsoft.SqlServer.Types assembly in GAC. I know how to install using nuget in project folder but I want it in GAC.
Don’t try to GAC it. Add the NuGet package to your project instead.
https://www.nuget.org/packages/Microsoft.SqlServer.Types

Could not load file or assembly 'Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' in Azure Functions

I am refering a C# library project from my Azure Function (Service bus queue trigger). The library is referencing the Newtonsoft nuget version 10.0.1.
While running the function locally on my visual studio, it gives this error .
{"Could not load file or assembly 'Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed' or one of its dependencies. The system cannot find the file specified.":"Newtonsoft.Json, Version=10.0.0.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed"}
I tried downgrading to version 10.0.0, but the issue is there.
I stumbled upon this issue link : https://github.com/Azure/azure-functions-vs-build-sdk/issues/107.
And tried downgrading to 9.0.1. But even then the error still occurs.
Note: The library project reference several other library projects which are also referencing Newtonsoft. I am keeping the same version of the nuget all the sub projects.
How to solve this issue?
Pointing all the Newtonsoft dlls in all the sub libraries to version to 9.0.1 solved the issue.

Missing Dependency: Castle.DynamicProxy2 after install LINQtoExecl from NuGet

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?

Categories

Resources