0

I want to use this wrapper in MonoGame but I get an error message if I use the code from the wrapper website.

Wrapper StatsIO

I downloaded the wrapper project and added the project to my solution in Visual Studio. After that, I created a reference from my project to the wrapper project.

Then, I copied this code to my project:

 var client = new StatsIOClient("Client-ID", "Client-Secret");
 await client.Statistics.CreateAsync("Stats-Id", "Username");

But something went wrong, because I get these error message:

Error CS1501: No overload for method 'CreateAsync' takes 2 arguments (CS1501)

What is wrong with the code? How can I use the wrapper project in my Visual Studio project to send and receive leaderboard scores?

Dropbox link to my Visual Studio project: my project

using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using StatsIO.Objects;
using StatsIO;

namespace LeaderboardTest
{
public class Game1 : Game
{
    GraphicsDeviceManager graphics;
    SpriteBatch spriteBatch;

    public async void NewClient()
    {
        var client = new StatsIOClient("Client-ID", "Client-Secret");
        await client.Statistics.CreateAsync("Stats-Id", "Username");
    }


    public Game1()
    {
        graphics = new GraphicsDeviceManager(this);
        Content.RootDirectory = "Content";
        graphics.IsFullScreen = true;
    }

    protected override void Initialize()
    {
        base.Initialize();
    }

    protected override void LoadContent()
    {
        spriteBatch = new SpriteBatch(GraphicsDevice);
        NewClient();    
    }

    protected override void Update(GameTime gameTime)
    {           
        base.Update(gameTime);
    }

    protected override void Draw(GameTime gameTime)
    {
        graphics.GraphicsDevice.Clear(Color.CornflowerBlue);

        base.Draw(gameTime);
    }
}
}
Bryan
  • 187
  • 5
  • 1
    first things first, you should read the errors more closely, "The 'await' operator can only be used within an async method. Consider marking this method with the 'async' modifier and changing its return type to 'Task'." it's saying right there, you should make your method async, you should read what async methods are: https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/concepts/async/ – Ricardo Dias Morais May 13 '19 at 13:41
  • And for the first error, this is the SO post i advice you to take a look: https://stackoverflow.com/questions/4764978/the-type-or-namespace-name-could-not-be-found – Ricardo Dias Morais May 13 '19 at 13:45
  • Thanx. I changed my code but I still get the "The type or namespace name StatsClient" error message and I don't understand what I'm doing wrong. – Bryan May 13 '19 at 14:12
  • there is no class StatsClient, it is called StatsIOClient. The docs appear to be wrong – Jason May 13 '19 at 14:29
  • I guess that you are missing an reference, hover StatsClient and press ALT+Enter, and see if it recommends any directive or assembly – Ricardo Dias Morais May 13 '19 at 15:08
  • just saw @Jason comment, i assumed that StatsClient was the correct class, nice catch Jason – Ricardo Dias Morais May 13 '19 at 15:10
  • StatsIOClient works. But now I get a new error message in the second line: No overload for method 'CreateAsync' takes 2 arguments (CS1501) – Bryan May 13 '19 at 15:15
  • 1
    Please take the time to read the code for the library. CreateAsync only has one argument, a name. I don’t think any of the docs are accurate, you will need to read the code – Jason May 14 '19 at 03:04

0 Answers0