-
Notifications
You must be signed in to change notification settings - Fork 425
Unit Test project(.NET 4.7) cannot load System.ValueTuple #476
Comments
Does adding these properties to the test project's csproj file help?: <PropertyGroup>
<AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
<GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
</PropertyGroup> |
@dasMulli Unfortunately BindingRedirect does not help. :'( |
.NET Standard 2.0 호환성 문제로 인해 마이그레이션을 연기합니다. 참고: dotnet/standard#476 This reverts commit d7bd6c9.
.NET Standard 2.0 호환성 문제로 인해 마이그레이션을 연기합니다. 참고: dotnet/standard#476 This reverts commit e36dcbc.
.NET Standard 2.0 호환성 문제로 인해 마이그레이션을 연기합니다. 참고: dotnet/standard#476 This reverts commit 0cd42cf.
This issue is easily reproduced by creating a .Net Standard 2.0 project with a function that uses a ValueTuple (such as The exception occurs when the ValueTuple type is needed - not when a ValueTuple is passed from the .Net Standard to .Net Framework project. Actually, the ValueTuple does not even need to be used in the .Net Framework project. When running under a .Net Core 2, the type is A workaround is to use a binding redirect in app.config:
However, this does not work in all situations. For example, some Unit Tests setups will execute from a separate folder and will not load the unit test projects app.config. Also, ComVisible projects will not use the app.config. It seems that a simple version number change would resolve the issue. I've seen quite a few issues on github due to the problem. This shows that many people are having trouble and spending time on this... |
Unfortunately that isn't possible because there are different assembly versions on different platforms and they already exist. I agree this issue can be painful but the general issue stems from the .NET Framework being much more strict with assembly binding which is why you need the binding redirects. If you guys can give me the scenarios where the binding redirects aren't working I can try and help figure out a solution. |
These 2 situations are fairly easy to reproduce: ComVisible: In a .Net Framework project, expose a class as PowerShell: Using the same .Net Framework object (ComVisible not necessary), Import the dll into powershell, use New-Object and call the function. Powershell does not use the app.config file. |
@ChrisW13 thanks for the scenarios. @ericstj @terrajobst do you guys know whether the COM activation honors binding redirects? For the Powershell or any case where there is an extension model (msbuild is another example) you are at the mercy of the host application to correctly load dependencies. In those cases you essentially are targeting a custom platform that the host application defines and you can only use things they allow. This isn't new but it is true that using .NET Standard 2.0 might make some of these issues more common. So there isn't any one generic solution to these problems depending on the host you might have to solve them differently,. |
Perhaps helpful: steps above didn't work for me with VS 2017 15.3.3, but started working with VS 2017 15.3.4. |
Can't seem to get this to work when running an azure function against a .net standard library |
That's probably because Azure Functions don't work with .NET Standard 2.0 yet. |
Not even precompiled? |
This got things working for me. Seeing as there isn't a app.config this fix seems to work. |
I don't have an app.config file in my MS unit test projects, how do I apply the workaround? |
Unit tests (both mstest and xunit) use the .dll.config convention. |
NUnit picks up .dll.config as well. |
VS2017 15.4.0 here. not a Core2.0 project & the System.ValueTuple won't update / won't redirect. |
I am now having this issue as well. I created an Azure Function (HttpTrigger). It runs locally and even runs while deployed to Azure. However, it fails during CI check-in using VSTS with the same error message as above. I have tried the code workaround, I have tried added System.ValueTuple thru NuGet, all have failed. Is there a solution to have this build in VSTS? |
VS 15.5.7, .NET Standard 2.0, Azure Function project. Microsoft.NET.Sdk.Functions Error System.IO.FileNotFoundException: Could not load file or assembly 'System.ValueTuple, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The system cannot find the file specified. |
Deleting the following folder worked for me. Project now compiles. Visual Studio 15.5.7, .NET Standard 2.0, Microsoft.NET.Sdk.Functions (1.0.8) |
I'm closing this because it doesn't bother me anymore. |
…ckery described here: dotnet/standard#476
I ran into this problem today and solved by applying multiple framework targets for the .net-standard project. That way the compiler compiles a version for each framework and links the correct one.
Note that it's TargetFrameworkS, plural. |
Unit Test project(.NET 4.7) referencing .NET Core library using value tuple cannot load System.ValueTuple assembly.
But console client application works correctly.
You can repro with code from https://github.com/gyuwon/ValueTypeTestingProblem
The whole message:
As I replied on the original issue, it can be solved by making library project to target multiple frameworks.
But it's just a work-around, not a solution.
I think it's not a single ValueTuple problem. There's some referencing issue on .NET Standard 2.0.
For example this issue on Azure Function(Web Job) project with .NET Standard 2.0 library, looks like similar: Azure/azure-functions-host#1792
The text was updated successfully, but these errors were encountered: