bchavez / Coinbase

:moneybag: A .NET/C# implementation of the Coinbase API.
https://developers.coinbase.com/api/v2
MIT License
170 stars 93 forks source link

System.IO.FileNotFoundException: Could not load file or assembly 'System.Net.Http, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. #74

Closed astrohart closed 3 years ago

astrohart commented 3 years ago

Version Information

Software Version(s)
NuGet Package 6.0,1
.NET Core? n
.NET Full Framework? 4.8
Windows OS? Win 10 Version 1909
Linux OS? n
Visual Studio? 2019 Enterprise 16.8.4

What is the expected behavior?

That the following code works:

            var result = new ApiKeyConfig
            {
                ApiKey = parms.ApiKey,
                ApiSecret = parms.ApiSecret
            };

What is the actual behavior?

Instead, it throws a FileNotFound exception:

System.IO.FileNotFoundException: Could not load file or assembly 'System.Net.Http, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. The system cannot find the file specified. at Flurl.Http.FlurlClient..ctor(String baseUrl)

I am using Flurl 3.0.1 and Flurl.Http version 3.0.1 NuGet packages.

Any possible solutions?

Tried doing a Update-Package on my Solution in the Package Manager Console and deleting bin and obj folders and doing a Restart of Visual Studio.

How do you reproduce the issue?

Just by running the code.

However, the following Unit Test passes:

using Coinbase;
using NUnit.Framework;

namespace MyTests
{
    [TestFixture]
    public class MyTestFixture
    {
        [Test]
        public void Test_Constructing_ApiKeyConfig_DoesNotThrowException()
        {
            ApiKeyConfig config = null;

            Assert.DoesNotThrow(() => config = new ApiKeyConfig
                {
                    ApiKey = "******",     // shhhh, it's a secret!
                    ApiSecret = "*********"     // shhhh, it's a secret!
                }
            );

            Assert.IsNotNull(config);
        }
    }
}

BTW - the asterisks in the listing above are just for security purposes. I am passing a valid API key and secret here.

Do you have a unit test that can demonstrate the bug?

No. Like I said earlier, I am baffled by this. I know this is around where the error is occurring because I've done logging down to this point.,

Can you identify the location in the source code where the problem exists?

Basically, but I get an error in my library source code and I do not receive an error during unit testing.

If the bug is confirmed, would you be willing to submit a PR?

Yes, absolutely. One concern I would have is, there seem to be pre- and post-build events configured to automatically push changes to GitHub on build. If I were to fork, I'd also need guidance on how to properly disable such code for testing purposes. The extensions or build events appear to push directly to your master, even from a fork.

astrohart commented 3 years ago

Just a quick update, I did a fork of this project and then cloned it to my local machine. Then, out of an abundance of caution, before building, I deleted the .git folder from the cloned repo to ensure that any remotes are also purged. This way there is very little chance of a screw up.

bchavez commented 3 years ago

Hi @astrohart,

Thanks for posting the issue. I want to say it seems like a binding issue. As you might know, the part of the CLR that is responsible for loading assemblies is called the Fusion loader. When the runtime needs to load a Type; Fusion is invoked to find the DLL responsible for that Type.

What it sounds like to me is; something in your project has a hard reference to a .NET framework assembly: System.Net.Http, Version=4.2.0.0 at this exact version.

Some things to check:

Let me know what you find.

Thanks, Brian