-
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
net40 application with Microsoft.Bcl.Async cannot resolve dependencies #7895
Comments
@dsplaisted can you help out here? |
same issue |
Same here. We switched back to VS2015 because we need to support NET4 targets. |
Same issue, I cannot use the StackExchange.Redis client in my library targeting 4.0, and 4.5 and netstandard... |
same here, any workaround? |
One workaround for that problem. And add App.config to project (in vs add-> new item-> application configuration file):
When you target multiple frameworks do remember to change condition for import and App.config. For example to something as
|
@rguryanov This does not work for me. Maybe I am doing something wrong. Could you explain where to put the .targets file etc. Maybe post example .csproj. Thanks a lot. Edit: I think my issue is that I have the BCL stuff in a class library and the workaround does not seem to work for those. |
I also have class library which uses Microsoft.Bcl.Async. I also tried @rguryanov's instructions, and also couldn't get them to work (the version of System.Threading.Tasks which it claimed a dependency on changed according to the binding redirect, but the rest of the error stayed the same). |
@Mats391 @canton7 |
@rguryanov thanks! That's for a console app. The challenge we have is making something similar work for a class library. |
@canton7 |
@rguryanov Thanks a lot, that works!
Solved it by targeting
|
I wonder if the DLL ships out of CoreFX? (@danmosemsft @weshaggard) cc @dsplaisted |
No, those libraries shipped out of our old Roxel tree. We've published the source code as part of reference source. I'm not entirely sure why this doesn't work. I'll take a look. Setting AGBR should have fixed the issue but it doesn't. |
It turns out that the Microsoft.Bcl.Build has a targets file which adds the right binding redirects which is added to the project via Install.ps1. So it doesn't work with To work with @terrajobst, @ericstj, @weshaggard, thoughts on this? |
Any news for any workaround on this issue? |
It already does this in the latest version. |
@rguryanov your example maybe work when OutputType is Exe,but Library did not this problem had be solved in this by @ericstj just to add
app.net40.config like below:
|
For library assemblies, just set the app.config to output as "Content" |
Alternative solution. Used it to fix problems with finding dll dependencies (after regasm and when calling from a vbs file via COM): using System;
using System.IO;
using System.Reflection;
#nullable enable
namespace Utilities
{
public static class XpUtilities
{
private static bool IsFixed { get; set; }
public static void FixAsyncAssemblyResolve()
{
if (IsFixed)
{
return;
}
IsFixed = true;
AppDomain.CurrentDomain.AssemblyResolve += OnAssemblyResolve;
}
private static Assembly? OnAssemblyResolve(object sender, ResolveEventArgs args)
{
switch (args.Name)
{
case "System.Threading.Tasks, Version=1.5.11.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a":
var path = Assembly.GetExecutingAssembly().Location;
var folder = Path.GetDirectoryName(path);
return folder == null
? null
: Assembly.LoadFrom(Path.Combine(folder, "System.Threading.Tasks.dll"));
default:
return null;
}
}
}
} |
Just to mention because I stumbled across this problem: you need to copy the *.exe.config file from the build folder into your desired output folder, too. Otherwise, the .dlls could not be referenced even when you performed the steps above. |
Steps to reproduce
Create a
net40
application that referencesMicrosoft.Bcl.Async
and uses await:project.csproj:
Program.cs:
Start with
dotnet run
Expected behavior
Program should start.
Actual behavior
Creates errors
Environment data
dotnet --info
output:Side Note:
Similar behaviour with
Microsoft.Net.Http
which fails to resolveSystem.Net.Http
.The text was updated successfully, but these errors were encountered: