FluentFTP has old dependency to Microsoft.Extensions.Logging.Abstractions - c#

Currently I am developing a azure function. I use Net6.0. I have multiple imports. At least one with ftp and one with http.
So I imported both packages via nuget. But if I start my function, the following error occurs:
System.IO.FileNotFoundException: 'Could not load file or assembly 'Microsoft.Extensions.Http, Version=7.0.0.0, Culture=neutral, PublicKeyToken=...'. The system cannot find the file specified.'`
This error is thrown because of a dependency of FluentFTP:
If I downgrade Microsoft.Extensions.Http to Version 6.0.0. The application starts without any error. Or, if I remove the Microsoft.Extensions.Http package, it also works (then the depency has version 2.2.0).
But why is this a problem with the newest version? Is there a way of using all packages with the newest version?

You are targeting net6.0 and the Microsoft.Extensions.Http dependency you are trying to install is meant for net7.0.
You can check that versions are named according to the .net version - https://www.nuget.org/packages/Microsoft.Extensions.Http/7.0.0#versions-body-tab
That is why you should use Microsoft.Extensions.Http version 6.0.0 or below.

Related

.NET Standard library - Could not load file or assembly 'System.Runtime.Caching'

I build a library using the latest .NET Standard version. It all works OK.
The problem occurs when I add the System.Runtime.Caching NuGet package. I tried to add all stable versions from 4.5 to 4.7. I get the following error for any version, when trying to use classes from this package.
Could not load file or assembly 'System.Runtime.Caching, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified."
In Asp.Net core app, i was referencing some libraries and it caused an issue when i tried use those libraries.
I had to add System.Runtime.Caching, because my libraries were unable to find them, which is not available by default in asp.netcore web api project. Hope this will help someone. You can install them from nuget package manager.
Uninstall System.Runtime.Caching package with NuGet package manager and close your visual studio. Than install this package again.
If it's not fixed the problem , check your csproj file and references in your project for version conflict or mismatch.

Entity Framework Core results in could not load netstandard

I am running Azure function with a Http trigger using .NET Core 3.1 in Visual Studio 2019 Version 16.5.0 Preview 1 and I am getting the following errors:
The 'HttpTriggerCSharp' function is in error: Unable to load one or more of the requested types. [12/25/2019 9:32:30 PM]
Could not load file or assembly 'netstandard, Version=2.1.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified. [12/25/2019 9:32:30 PM]
Microsoft.Azure.WebJobs.Host: Error indexing method 'HttpTriggerCSharp'. Microsoft.Azure.WebJobs.Host: cannot bind parameter 'log' to type ILogger. Make sure the parameter type is supported by the binding. If you're using binding extensions (e.g. Azure Storage, ServiceBus, Timers, etc.) make sure you've called the registration method for the extension(s) in your startup code (e.g. builder.AddAzureStorage(), builder.AddServiceBus(), builder.AddTimers(), etc.).
The error appears when I installed the nuget package for the Microsoft.EntityFrameworkCore.SqlServer.
Any idea how to fix this?
It turned out I was running v2 of the Azure Function runtime and when I changed it to v3 in the FunctionApp1.csproj file it started to work.
<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<AzureFunctionsVersion>v3</AzureFunctionsVersion>
</PropertyGroup>
Assuming Solution 1.
Install latest .NET Core SDK
Assuming Solution 2.
Delete the bin/ and obj/ folders and rebuild the solution.
Assuming Solution 3.
unistall installed package and reinstall
dotnet add package Microsoft.EntityFrameworkCore.SqlServer --version 3.1.0
.NET Core 2.0 and later, restore is done automatically with dotnet build and dotnet run, but do it manually some time helps

OOXML want to use updated version of DocumentFormat.OpenXml dll version is 2.8.1.0

After updating DocumentFormat.OpenXml dll version to is 2.8.1.0.
I am getting the following error.
System.IO.FileNotFoundException - Could not load file or assembly 'System.IO.Packaging, Version=4.0.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
I tried as follows, but getting the exception
PM> Install-Package System.IO.Packaging
Attempting to gather dependency information for package
'System.IO.Packaging.4.5.0' with respect to project 'xxx', targeting '.NETFramework,Version=v4.5.2'
Gathering dependency information took 1.93 ms
Attempting to resolve dependencies for package 'System.IO.Packaging.4.5.0' with DependencyBehavior 'Lowest
Resolving dependency information took 0 ms
Resolving actions to install package 'System.IO.Packaging.4.5.0'
Resolved actions to install package 'System.IO.Packaging.4.5.0'
Retrieving package 'System.IO.Packaging 4.5.0' from 'nuget.org'.
Install failed. Rolling back...
Package 'System.IO.Packaging.4.5.0' does not exist in project 'xxx'
Package 'System.IO.Packaging.4.5.0' does not exist in folder 'E:\Working\Projects\xxx-OOXML-Aug22\packages
Executing nuget actions took 1.76 sec
Install-Package : Could not install package 'System.IO.Packaging 4.5.0'. You are trying to install this package into a
project that targets '.NETFramework,Version=v4.5.2', but the package does not contain any assembly references or content
files that are compatible with that framework. For more information, contact the package author.
Note: Our project .net version is 4.5.2
Language: c#
I have download OpenXML 2.8.1 and use it in a .net 4.5.2 project. It works for me without error.
According to you error message, did you use other dll? Did you use System.IO.FileSystem.Primitives?
If you do not use OpenXML and just use the System.IO.FileSystem.Primitives, will you get this error?

Could not load file or assembly system.memory version 4.1.0.0

I have asp.net core project which runs on Asp.Net Core V2.1.0 which has signal r integrated. I have downloaded a sample project from aspnetbrolerplate. When I try to run the application it gives me following error.
System.IO.FileNotFoundException: 'Could not load file or assembly 'System.Memory, Version=4.1.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51'. The system cannot find the file specified.'
Can anyone please suggest me possible solution for this issue.
I found installing the System.Memory NuGet package resolves the issue.
It is confusing that earliest version is 4.5.1, but if you install it, you will find the assembly versioned a System.Memory, Version=4.1.0.0.
For my .NET Framework project I installed NuGet version 4.5.4 which contains System.Memory, Version=4.0.1.1 assembly.
I found that this is a known issue for UWP. Update to Asp.Net Core 2.1.1 and Microsoft.AspNetCore.SignalR.Client NuGet Package to at least 1.0.1, which has a fix for this UWP issue.
Maybe it also fixes your issue.

C# program deployment issues

I want to deploy my C# program, but I'm having issues with running it on another computer.
I copied the entire folder from bin/debug to another computer and tried running the program. I receive the following error message:
Unhandled Exception: System.AggregateException: One or more errors occurred. ---> System.IO.FileNotFoundException: Could not load file or assembly 'System.Threading.Tasks.Dataflow, Version=4.5.24.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified.
I thought it might be the issue of the computer not having .NET Framework 4.5.2 and tried downloading the installer from Microsoft but the installer states .NET
Framework 4.5.2 or a later update is already installed on this computer.
This assembly it's not distributed with .Net Framework 4.5 you'll need to add to you project by NuGet, search online in NuGet package manager for Microsoft.Tpl.Dataflow.
I got an same problem and my problem was a missing project reference after an update of an dependent package.
I had to reinstall my nuget packages with the command Update-Package –reinstall in the Package Manager Console.
https://learn.microsoft.com/en-us/nuget/consume-packages/reinstalling-and-updating-packages
After that the project references was newly added.

Categories