-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Error loading System.Threading.Tasks.Extensions (on version 15) #1462
Comments
What version of CsvHelper is used when using framework 4.8? |
CsvHelper has it listed for everything before <!-- .NET 4.5 -->
<ItemGroup Condition="'$(TargetFramework)' == 'net45'">
<PackageReference Include="Microsoft.CSharp" Version="4.5.0" />
<PackageReference Include="System.Threading.Tasks.Extensions" Version="4.5.3" />
<PackageReference Include="System.ValueTuple" Version="4.4.0" />
</ItemGroup>
<!-- .NET 4.7 -->
<ItemGroup Condition="'$(TargetFramework)' == 'net47'">
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="1.1.0" />
<PackageReference Include="Microsoft.CSharp" Version="4.5.0" />
<PackageReference Include="System.Threading.Tasks.Extensions" Version="4.5.3" />
</ItemGroup>
<!-- .NET Standard 2.0 -->
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.0'">
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="1.1.0" />
<PackageReference Include="Microsoft.CSharp" Version="4.5.0" />
<PackageReference Include="System.Threading.Tasks.Extensions" Version="4.5.3" />
</ItemGroup>
<!-- .NET Standard 2.1 -->
<ItemGroup Condition="'$(TargetFramework)' == 'netstandard2.1'">
<PackageReference Include="Microsoft.CSharp" Version="4.5.0" />
</ItemGroup> |
I'm getting this error with CsvHelper 15 and 14 (netstandard2.0). I tried it on different machine that uses 4.7, getting same error. Those are versions that has Tasks.Extensions as dependency. v13 doesn't have direct dependency on Tasks.Extensions, but Bcl requires it too. Maybe this is because Bcl and CsvHelper refer to different version of Task.Extension? I haven't tested it on actual net framework app (only on core), so this also could be some powershell specific thing. |
Maybe it's related to this dotnet/runtime#10674 Can you see if that workaround works in your scenario? |
Turns out this is because different version indeed. I tried to build CsvHelper from source downgrading Tasks.Extensions to 4.5.2 and then was able to load it. If I keep 4.5.3 still getting same error. |
Can you try the |
OK, will try. They seemed to apply this to .net core console app, however in my case netcore console works fine |
I think I misunderstood something. I'll take a closer look. |
For some reason I though you were writing something that worked with PowerShell, and not just running a console app through PowerShell. |
OK. I suspect there might be an issue loading netstandard CsvHelper to netframework project |
If you reference CsvHelper net47 instead of netstandard2.0, does it work? |
Same. I realized it's more like an issue with Microsoft.Bcl.AsyncInterfaces. Somehow it doesn't like Tasks.Extensions 4.5.3, at least within windows powershell runtime (4.x). Wondering if regular netframework app can handle it, will try to test it later |
It seemed to be a global issue, not just powershell. Just tried to create net47 console app and getting same error. net45 works, but it has no dependency on Bcl. I guess we need to downgrade Tasks.Extensions to 4.5.2. for Net47 and NetStandard, unless there is some better solution. |
I opened an issue with corefx, we'll see what they say |
My target framework is 472, and I get the same issue here. Installing CsvHelper 15.0.0, but keep getting the below errors
Initially, I thought it was because of the Microsoft.Bcl.AsyncInterfaces which I get one with 1.0.0, but after upgrading to 1.1.0. I'm still having the same error, and I upgrade all the System.Threading.Tasks.Extensions to 4.5.3. And from nuget package manager, I should be able to use Microsoft.Bcl.AsyncInterfaces 1.1.0 with System.Threading.Tasks.Extensions to 4.5.3. However, I keep getting the same error. From the Fusion log, it shows this.
I already spend a day fixing this. I think I'll try downgrade the CsvHelper now. |
In the end, I downgrade to 14.0.0 to fix the issue |
Same problem for us. We are targetting .NET Framework 4.8 and get assembly load failures at runtime when dynamically loading in assemblies into IoC container.
Looking at the assembly references in DotPeek, it looks like |
I just pushed |
It works now |
@mikeTWC1984 Do you have a link to your issue with CoreFX? |
I think this is the issue mentioned in https://stackoverflow.com/questions/60194368/could-not-load-file-or-assembly-system-threading-tasks-extensions-version-4-2 |
FWIW downgrading to 13.0 also worked around this, and without any code changes to the code I had previously written to use 15.0. |
Now with
I wasn't getting this with |
@Methuselah96 What is trying to use |
@JoshClose Here is the output of
|
Do you have this redirect in your config file?
|
That's a cool tool though. I haven't used that one before. |
I figured it out. The binding redirect was correct, but I just had forgotten to install a transitive dependency in my test project. I'm not sure why that would give me that specific error message with 15.0.1, but not 15.0.0, but it doesn't matter. All good, sorry to bother you. And, yeah, that tool is the only thing that provides sanity in the world of C# assemblies. |
@Methuselah96 would you mind sharing the details of what you meant by transitive dependency? What did you actually have to change in your project? Thanks! |
@DaveInCaz I had ProjectA and ProjectA.Tests (.NET Framework). ProjectA had the NuGet package CsvHelper installed, but ProjectA.Tests did not. Again, I'm not sure how it worked before 15.0.0 -> 15.0.1, since ProjectA.Tests needs to have all the dependencies that ProjectA has. But installing CsvHelper in ProjectA.Tests fixed it for me. |
Simple and short Answer:- Make sure your EFCore installed version and EF related Other NuGet packages have same version. Like:- EFCore v5.0.0 Preview 3.2..... Hope this will help you, |
We just spent a morning working through this issue. In our case, both of our Dev machines ran fine, but we got the error when our CI/CD build deployed to Azure. There we found that System.Threading.Tasks.Extensions.dll was truly not being deployed to the bin folder on the web site. The file did exist in our local bin folders. In our situation, the reference was in one assembly and that project was referenced in the web site project being deployed. We removed the NuGet packages for CsvHelper, Microsoft.Bcl.AsyncInterfaces and System.Threading.Task.Exensions. We then went through every project in the solution and removed any left over binding redirects and verified that every package.config file had no references to any of the packages. Then we shut down Visual Studio, deleted all of the bin and obj folders from all of the projects and removed any left over packages from the packages folder. We then re-started VS, re-installed CsvHelper 15.0.0, did a local build, verified it was correct, then checked it in for a new CD/CI deployment. Lo and behold, the .dll was copied to the web site! I can't say why it worked. The NuGeet package version for System.Threading.Tasks that got installed is 4.5.4. If you right click on the properties for the file, it says it's 4.2.01. If you track down the file based on the path in the properties window or look in the bin folder and check the file properties, it's 4.6.28619.1. Go Figure. If you run into this problem, I recommend looking in your bin folder for that file. If it's not there, you know why you get the exception. What it doesn't tell you is why the file isn't there. |
THANK YOU, @MikeYeager
|
I also have this bug and have no idea what I need to solve this. I'm NOT downgrading System.Threading.Tasks.Extensions. The version I have on that is 4.2.0.0 and the error says:
Really have no idea what to do here. |
For anyone still experiencing this error. I fixed it by also updating the Microsoft.Bcl package to the latest version (1.1.10). Make sure to have the most recent versions of Microsoft.Bcl.AsyncInterfaces & Microsoft.Bcl.Build as well. Microsoft.Bcl.AsyncInterfaces has a dependency on System.Threading.Tasks.Extensions. |
@pvg8v6g If you can provide a sample repository that can reproduce the same issue, I would like to troubleshooting for you. |
Steps taken by @MikeYeager worked for me too. |
encounter the same problem again, and tried with |
A little difference from my experience, we encounter this problem in web site project. |
Does anyone see a change that can be made in CsvHelper to fix this, or is it just an issue within Microsoft/Visual Studio? |
The question would be, did CsvHelper really depends on System.Threading.Tasks.Extensions.dll? When I check the output folder(build project without dependency of ), and check the dependency, I find both CsvHelper and Microsoft.Bcl.AsyncInterfaces depend on System.Threading.Tasks.Extensions. This is weird, since I have removed the dependency of System.Threading.Tasks.Extensions for CsvHelper. Microsoft.Bcl.AsyncInterfaces, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51 |
@JoshClose Just found you have released CsHelper 16.0, https://www.nuget.org/packages/CsvHelper/16.0.0 Actually Microsoft.Bcl.AsyncInterfaces 1.1.0 has dependency of System.Threading.Tasks.Extensions (>= 4.5.2) for net461. And you only need to specify Microsoft.Bcl.AsyncInterfaces (>= 1.1.0), from my experience I believe the nuget install will handle the dependency automatically for users. |
The only thing we need to figure out here is, when removed the dependency System.Threading.Tasks.Extensions from net47, the project build successfully, Why the compiled the dll file has a dependency of System.Threading.Tasks.Extensions? |
It seems the CsvHelper depends on System.Threading.Tasks.Extensions for ValueTask. And even if I removed System.Threading.Tasks.Extensions dependency from net47, visual studio did not report error, something wrong here, might a bug of visual studio. |
@JoshClose Finally there should be no problem caused by CsvHelper, when they encounter, they just need to check the bindingRedirect in their config file. You can close this issue. Ask them to file new issue with a reproduce repository next time, and I would like to do the troubleshooting. |
@chucklu Thanks. |
I am still getting this issue in the latest version of CsvHelper 18.... I have tried every stated above and nothing helps. The only thing I haven't tried is downgrading CsvHelper. === Pre-bind state information ===
|
@kvillines Looks like you might have an |
@Methuselah96 I added the redirect to try and fix the issue. The project builds fine but at runtime it tries to load 4.2.0.0 of the assembly. I have the latest assembly from NuGet which is 4.5.4. I just pulled out the redirect and it didn't matter. I might just build a unit test project from scratch and see if I can make it work. |
@kvillines The NuGet version number is not the same as the version in the binding redirects. Try |
@Methuselah96 oh, so the version it shows me in the csproj file isn't really the correct one? |
@kvillines Correct, the version in the csproj is the NuGet package version. The version in the binding redirects is the assembly version. Here's some documentation on the difference: https://docs.microsoft.com/en-us/dotnet/standard/library-guidance/versioning. |
@Methuselah96 that worked!! Thank you very much. |
Hoping this message will help someone who see it.. I was still getting the message: I had tried the full routine mentioned by @tscilipoti above - made no difference. Built and deployed the program, and got the message: System.IO.FileLoadException: Could not load file or assembly 'Microsoft.Bcl.AsyncInterfaces, Version=1.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040) So, in the 'runtime' section of my 'App.config' file, which was included in my InnoSetup installer, I changed :
to
And it all worked! |
I'm trying to create some netstandard2.0 class library using CsvHelper, and consume it with PowerShell. Everything works with CsvHelper 13. Version 14/15 work with PowerShell Core (based on .net core 3.1), but getting error below if using with Windows Powershell (using 4.8 framework).
Since it works with version 13, hopefully there is some easy fix
The text was updated successfully, but these errors were encountered: