JKorf / Bybit.Net

A C# .netstandard client library for the Bybit REST and Websocket V5 API focusing on clear usage and models
https://jkorf.github.io/Bybit.Net/
91 stars 62 forks source link

Multiple constructors accepting all given argument types have been found in type 'Bybit.Net.Clients.BybitRestClient' #191

Closed b-f- closed 3 months ago

b-f- commented 4 months ago

Repeat Use AddBybit Helper without params to register DI client services. Note: could be due to my local code changes, but i left constructors intact.

Environment Android (Debug, Release, R8 disabled). For some reason this issue has never occurred on Windows builds.

<RunAOTCompilation>False</RunAOTCompilation>
<PublishTrimmed>False</PublishTrimmed>

Issue seems to not have appeared before upgrading to <PackageReference Include="CryptoExchange.Net" Version="6.2.5" /> but now it persists even with <PackageReference Include="CryptoExchange.Net" Version="6.2.3" /> so CryptoExchange.Net version could be unrelated.

public Initializer(IServiceProvider serviceProvider)
{
    try
    {
        serviceProvider.GetServices<IBybitRestClient>(); // <- this will throw depending on how the code is built
        serviceProvider.GetServices<IBybitSocketClient>();
    }
    catch (Exception ex)
    {
    }
}

Workaround Use PublicRestApiClient = new BybitRestClient((_) => { }); instead of DI.

JKorf commented 4 months ago

Hi, is there a specific reason you have an explicit reference to CryptoExchange.Net? Normally just having a PackageReference to the Bybit.Net library would be fine. That also makes sure that you're not missmatching the 2 libraries.

I haven't seen this issue before, but it might have to do with different runtimes since you only see it on Android. I'll see if I can find anything

b-f- commented 4 months ago

Hi, is there a specific reason you have an explicit reference to CryptoExchange.Net? Normally just having a PackageReference to the Bybit.Net library would be fine. That also makes sure that you're not missmatching the 2 libraries.

I haven't seen this issue before, but it might have to do with different runtimes since you only see it on Android. I'll see if I can find anything

Hi. I switched to CryptoExchange.Net src trying to figure out which constructors were conflicting (with no success). Maui was behaving strangely and producing a blank screen on Android, randomly, after upgrading to 8.0.100. Turns out the reason for that was checking Break on All exceptions in Exception Settings, app just hangs with a blank screen on Android. Will probably switch back to using package soon.

Regarding ByBit.Net src fork I removed all but most recent API versions in the fork and set build target to net8.0, no other reason so far, it just works, and thank you for that, much appreciated :)