Skip to content
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

Exception executing the library with netcoreapp1.1: Could not load file or assembly 'System.Net.Http, Version=4.1.1.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified. #12

Closed
1 task done
sesispla opened this issue Jul 23, 2017 · 7 comments

Comments

@sesispla
Copy link
Contributor

sesispla commented Jul 23, 2017

@brendanburns as formal report about the issue found in PR #11

During unit testing found that severals tests, related with KubernetesUserCredentials, where broken reporting a 'Could not load file or assembly System.Net.Http'. Initially thought it was related with my computer, but after adding Travis-CI support found that the problem is also present in trusty environment with dotnet SDK 1.0.4.

Here is all information I found so far:

  1. It looks like minimum version present for System.Net.Http in netcoreapp1.1 (SDK 1.0.4) is 4.3.2. Trying a hard reference to downgrade the library through NuGet throws an error:
$ dotnet build
/Users/Sergio/Repositories/kubernetes/cli/csharp/src/KubernetesClient.csproj : error NU1605: Detected package downgrade: System.Net.Http from 4.3.2 to 4.1.1. Reference the package directly from the project to select a different version.  [/Users/Sergio/Repositories/kubernetes/cli/csharp/tests/tests.csproj]
/Users/Sergio/Repositories/kubernetes/cli/csharp/src/KubernetesClient.csproj : error NU1605:  KubernetesClient (>= 1.0.0) -> Microsoft.NETCore.App (>= 1.1.2) -> System.Net.Http (>= 4.3.2)  [/Users/Sergio/Repositories/kubernetes/cli/csharp/tests/tests.csproj]
/Users/Sergio/Repositories/kubernetes/cli/csharp/src/KubernetesClient.csproj : error NU1605:  KubernetesClient (>= 1.0.0) -> System.Net.Http (>= 4.1.1) [/Users/Sergio/Repositories/kubernetes/cli/csharp/tests/tests.csproj]
  1. IMO, System.Net.Http 4.1.1.1 dependency comes from Microsoft.Rest.ClientRuntime. Furthermore, note that 3.0.3 been unlisted, but we are still referencing 3.0.3.
  • A downgrade to Microsoft.Rest.ClientRuntime 2.3.8 do not fix the issue.
  1. Made a full battery test using all available SDKs with Travis-CI, with no luck. Either the solution do not build or we get the 'Could not load file or assembly System.Net.Http' exception.

Full log output as registered in Build#2

    k8s.Tests.KubernetesClientCredentialsTests.UsernameNull [FAIL]
      Assert.Throws() Failure
      Expected: typeof(System.ArgumentNullException)
      Actual:   typeof(System.IO.FileNotFoundException): Could not load file or assembly 'System.Net.Http, Version=4.1.1.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.

      Stack Trace:
           at k8s.Tests.KubernetesClientCredentialsTests.<>c.<UsernameNull>b__1_0()
    k8s.Tests.KubernetesClientCredentialsTests.PasswordNull [FAIL]
      Assert.Throws() Failure
      Expected: typeof(System.ArgumentNullException)
      Actual:   typeof(System.IO.FileNotFoundException): Could not load file or assembly 'System.Net.Http, Version=4.1.1.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.

      Stack Trace:
           at k8s.Tests.KubernetesClientCredentialsTests.<>c.<PasswordNull>b__2_0()
    k8s.Tests.KubernetesClientCredentialsTests.ValidUserPasswordIsSet [FAIL]
      System.IO.FileNotFoundException : Could not load file or assembly 'System.Net.Http, Version=4.1.1.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.

    k8s.Tests.KubernetesClientCredentialsTests.ValidTokenIsSet [FAIL]
      System.IO.FileNotFoundException : Could not load file or assembly 'System.Net.Http, Version=4.1.1.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.

    k8s.Tests.KubernetesClientCredentialsTests.TokenNull [FAIL]
      Assert.Throws() Failure
      Expected: typeof(System.ArgumentNullException)
      Actual:   typeof(System.IO.FileNotFoundException): Could not load file or assembly 'System.Net.Http, Version=4.1.1.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'. The system cannot find the file specified.
@brendandburns
Copy link
Contributor

Thanks for the details!

I'll ping the autorest folks and see if I can get them to see what the right solution is here.

@brendandburns
Copy link
Contributor

Quick update, I updated the project to use netcoreapp2.0 and things seem to work:

<TargetFramework>netcoreapp2.0</TargetFramework>

Can you see if that fixes things for you? I may just migrate forward to netcoreapp2.0 if that fixes things...

@brendandburns
Copy link
Contributor

Actually this was just for build. When I try to run the tests I seem to run into this:

xunit/xunit#1199

@sesispla
Copy link
Contributor Author

Asking @sergiomcalzada for help.

We've been having a look to netcoreapp2.0 (same result). Then had a look to System.Net.Http 4.3.2 Package, and found that internal version is 4.1.1.1, but the target framework is different:

Sergios-MacBook-Pro:packages Sergio$ monodis --assembly System.Net.Http/4.3.2/runtimes/
unix/ win/
Sergios-MacBook-Pro:packages Sergio$ monodis --assembly System.Net.Http/4.3.2/runtimes/unix/lib/netstandard1.6/System.Net.Http.dll
Assembly Table
Name:          System.Net.Http
Hash Algoritm: 0x00008004
Version:       4.1.1.1
Flags:         0x00000001
PublicKey:     BlobPtr (0x00002101)
        Dump:
0x00000000: 00 24 00 00 04 80 00 00 94 00 00 00 06 02 00 00
0x00000010: 00 24 00 00 52 53 41 31 00 04 00 00 01 00 01 00
0x00000020: 07 D1 FA 57 C4 AE D9 F0 A3 2E 84 AA 0F AE FD 0D
0x00000030: E9 E8 FD 6A EC 8F 87 FB 03 76 6C 83 4C 99 92 1E
0x00000040: B2 3B E7 9A D9 D5 DC C1 DD 9A D2 36 13 21 02 90
0x00000050: 0B 72 3C F9 80 95 7F C4 E1 77 10 8F C6 07 77 4F
0x00000060: 29 E8 32 0E 92 EA 05 EC E4 E8 21 C0 A5 EF E8 F1
0x00000070: 64 5C 4C 0C 93 C1 AB 99 28 5D 62 2C AA 65 2C 1D
0x00000080: FA D6 3D 74 5D 6F 2D E5 F1 7E 5E AF 0F C4 96 3D
0x00000090: 26 1C 8A 12 43 65 18 20 6D C0 93 34 4D 5A D2 93
Culture:

Sergios-MacBook-Pro:packages Sergio$ monodis --assembly System.Net.Http/4.3.2/runtimes/win/lib/netstandard1.3/System.Net.Http.dll
Assembly Table
Name:          System.Net.Http
Hash Algoritm: 0x00008004
Version:       4.1.1.1
Flags:         0x00000001
PublicKey:     BlobPtr (0x00001d00)
        Dump:
0x00000000: 00 24 00 00 04 80 00 00 94 00 00 00 06 02 00 00
0x00000010: 00 24 00 00 52 53 41 31 00 04 00 00 01 00 01 00
0x00000020: 07 D1 FA 57 C4 AE D9 F0 A3 2E 84 AA 0F AE FD 0D
0x00000030: E9 E8 FD 6A EC 8F 87 FB 03 76 6C 83 4C 99 92 1E
0x00000040: B2 3B E7 9A D9 D5 DC C1 DD 9A D2 36 13 21 02 90
0x00000050: 0B 72 3C F9 80 95 7F C4 E1 77 10 8F C6 07 77 4F
0x00000060: 29 E8 32 0E 92 EA 05 EC E4 E8 21 C0 A5 EF E8 F1
0x00000070: 64 5C 4C 0C 93 C1 AB 99 28 5D 62 2C AA 65 2C 1D
0x00000080: FA D6 3D 74 5D 6F 2D E5 F1 7E 5E AF 0F C4 96 3D
0x00000090: 26 1C 8A 12 43 65 18 20 6D C0 93 34 4D 5A D2 93
Culture:

Also tried to make a Assembly Redirect, but it makes no sense, since Assembly version is 4.1.1.1 also for package 4.3.2...

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
      <dependentAssembly>
        <assemblyIdentity name="System.Net.Http" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
        <bindingRedirect oldVersion="0.0.0.0-4.3.0.0" newVersion="4.1.1.1" />
      </dependentAssembly>
    </assemblyBinding>
  </runtime>
</configuration>

@sergiomcalzada could you please make a fast test on Windows with netcoreapp1.1 and without AssemblyRedirect?

@sergiomcalzada
Copy link
Contributor

Hello,

I tested it on windows and I discovered a missed package reference in the test project.

<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />

I created a pull request with some changes that runs all test (except KubernetesClientCredentialsTests PasswordNull)

Assert.Throws() Failure
Expected: typeof(System.ArgumentNullException)
Actual:   (No exception was thrown)
   at k8s.Tests.KubernetesClientCredentialsTests.PasswordNull() in C:\Repositorios\External\kubernetes-client\csharp\tests\KubernetesClientCredentialsTests.cs:line 34

@sesispla
Copy link
Contributor Author

Thank you @sergiomcalzada!

If I am correct, your PR is #14. Travis-CI looks good (two errors not related with this issue left to fix), so let's wait for the Merge to close the issue.

Thx!

@sesispla
Copy link
Contributor Author

Fixed in PR #14

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants