JKorf / Binance.Net

A C# .netstandard client library for the Binance REST and Websocket Spot and Futures API focusing on clear usage and models
https://jkorf.github.io/Binance.Net/
MIT License
1.03k stars 425 forks source link

creating a new client object with default options #441

Closed Amannda123 closed 3 years ago

Amannda123 commented 3 years ago

Hi there, when running my program in debug mode everything is fine and working as intended, however as soon as i compile it to a release version (standalone exe) it throws this error:

Unhandled exception. System.TypeInitializationException: The type initializer for 'Binance.Net.BinanceClient' threw an exception. ---> System.MissingMethodException: Method not found: 'Void CryptoExchange.Net.Objects.RestClientOptions.set_HttpClient(System.Net.Http.HttpClient)'. at Binance.Net.Objects.Spot.BinanceClientOptions..ctor(String spotBaseAddress, String futuresUsdtBaseAddress, String futuresCoinBaseAddress, HttpClient client) at Binance.Net.Objects.Spot.BinanceClientOptions..ctor(String spotBaseAddress, String futuresUsdtBaseAddress, String futuresCoinBaseAddress) at Binance.Net.Objects.Spot.BinanceClientOptions..ctor() at Binance.Net.BinanceClient..cctor() --- End of inner exception stack trace --- at Binance.Net.BinanceClient.get_DefaultOptions() at Binance.Net.BinanceClient..ctor() at LiquidationSniper.Program.Main(String[] args)

My Code looks like this: client = new BinanceClient(new BinanceClientOptions { ShouldCheckObjects = true, ApiCredentials = new ApiCredentials(config.ApiKey, config.ApiSecret), AutoTimestamp = true, LogVerbosity = logVerb, LogWriters = new List<TextWriter> { Console.Out }, AutoTimestampRecalculationInterval = TimeSpan.FromMinutes(10) });

this was fine in 5.x release of the wrapper..

4oplay commented 3 years ago

In addition to this is there an analogy to .SetDefaultOptions for M-Futures? This worked in 5.x releases. In 6.x it only works for Spot. BinanceClient.SetDefaultOptions(new BinanceClientOptions() { });

JKorf commented 3 years ago

It seems like a wrong version of CryptoExchange.Net is used to build the Release version. Can you try to clean the solution?

@4oplay All requests in version 6.x.x are made from the BinanceClient. So BinanceClient is no longer just for Spot, but also for USDT futures and Coin futures by using client.FuturesUsdt.xxx/client.FuturesCoin.xxx as opposed to client.Spot.xxx.

Amannda123 commented 3 years ago

I used every option to clear, build and rebuild in the menu, i cleared the bin folder still get the same error. i just updated the binance.net through the packet manager, do i have to update CryptoExchange.Net as well manually?

these versions are showing up during the build process 2>/r "C:\Users\user\.nuget\packages\binance.net\6.0.1\lib\netstandard2.1\Binance.Net.dll" 2>/r "C:\Users\user\.nuget\packages\cryptoexchange.net\3.0.14\lib\netstandard2.1\CryptoExchange.Net.dll"

JKorf commented 3 years ago

Those versions should be fine. Do you use any of the other libraries which also use CryptoExchange.Net? Maybe you have an older version of Bitfinex.Net for example, which references an older version of CryptoExchange.Net?

Amannda123 commented 3 years ago

no, im only using binance.net nothing else besides standard .net librarys :-/ any other suggestions? otherwise ill try to rebuild it in a complete new project file/folder

JKorf commented 3 years ago

I just tried it in a new application, self contained and it works in release. So I think there is some wonky caching going on.

Amannda123 commented 3 years ago

yep i 2nd that... created a new workspace just copied my files in and installed the binance.net => works like a charm :) thanks for your support