GithubHelp home page GithubHelp logo

Comments (15)

JKorf avatar JKorf commented on May 22, 2024

Hi, what version of the .Net framework do you use? You can find this by right clicking on your project, selecting Properties and it will tell you under Target Framework.

from binance.net.

colingresty avatar colingresty commented on May 22, 2024

Hi, ive tried 4.5.1 4.5.2 and 4.5 - all give the same error.
Thanks

from binance.net.

JKorf avatar JKorf commented on May 22, 2024

Is it possible for you to start using 4.6.1? The Binance.Net package is targeting .NetStandard 2.0, which sadly means .Net framework versions older than 4.6.1 are not supported, sorry!

from binance.net.

colingresty avatar colingresty commented on May 22, 2024

Hi, i just tried 4.6.1 and again got the exact same error. Here is how little is in the test project and im getting the error. :

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using Binance.Net;

namespace CP4
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

    private void button1_Click(object sender, EventArgs e)
    {
        using (var client = new BinanceClient())
        {
        }
    }
}

}

from binance.net.

JKorf avatar JKorf commented on May 22, 2024

Hm, that's weird. When I create a new .net 4.6.1 console project and add Binance.Net via the package manager it works. So I'm guessing it is something to do with your develop environment, although I'm not sure what it is..

from binance.net.

colingresty avatar colingresty commented on May 22, 2024

I just tried it in VS 2017 targetting .Net 4.6.1 and it compiles now but just hangs when i try and get prices from the exchange :(

from binance.net.

JKorf avatar JKorf commented on May 22, 2024

Can you try to run your code in a separate Task?

from binance.net.

colingresty avatar colingresty commented on May 22, 2024

Im sorry, i dont know what that means - im not a c# expert :)

from binance.net.

colingresty avatar colingresty commented on May 22, 2024

in a separate thread?

from binance.net.

JKorf avatar JKorf commented on May 22, 2024
Task.Run(() => {
    using(var client = new BinanceClient())
    {
        // use client
    }
});

from binance.net.

colingresty avatar colingresty commented on May 22, 2024

so i can now compile and run the extremely simple project, but i get no response, it just seems to run and do nothing. It can't be this hard?

from binance.net.

colingresty avatar colingresty commented on May 22, 2024

Hi, final comment before i give up on this.
everything in the example below compiles with no errors, textBox2.Text never gets populated.

(if i use c# WebClient Class i can talk to Binance exchange happily to get prices etc. so its not AV , Firewall etc)

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using Binance.Net;

namespace CP4
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

    private void button1_Click(object sender, EventArgs e)
    {
            using (var client = new BinanceClient())
            {
            textBox1.Text = "Before";
            var ping = client.Ping();
            textBox2.Text = "After";
            }

    }


}

}

from binance.net.

colingresty avatar colingresty commented on May 22, 2024

I guess i have to give up then.
Thats a shame, because this would have saved me a lot of hassle, but i just cant make the simplest use of Binance.Net work.
Thanks for trying anyway.

from binance.net.

JKorf avatar JKorf commented on May 22, 2024

The call hangs because you're trying to do an async await request from the UI thread, which probably isn't the best idea. If you use a seperate task for this as I suggested earlier it should work:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows.Forms;
using Binance.Net;

namespace CP4
{
    public partial class Form1 : Form
    {
    public Form1()
    {
        InitializeComponent();
    }

    private void button1_Click(object sender, EventArgs e)
    {
        Task.Run(() =>
            {
                using (var client = new BinanceClient())
                {
                    var result = client.Get24HPrice("ETHBTC");
                    if (result.Success)
                    {
                        Invoke(new MethodInvoker(() =>
                        {
                            textBox1.Text = "ETH price: " + result.Data.LastPrice;
                        }));
                    }
                }
            });
    }
  }
}

Note that the Invoke(new MethodInvoker() => is required because you update the UI from a different thread.

On another note, I've fixed some things in the latest version, if you download version 2.2.3 it should work with the code you had (no additional Task needed).

from binance.net.

colingresty avatar colingresty commented on May 22, 2024

Hi, Using a separate thread works :)
Thanks for your help (and patience)

from binance.net.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.