error CS0246 missing a using directive or an assembly reference: but there is

Hi,

I got the error

Assets/Error.cs(2,7): error CS0246: The type or namespace name `RestSharp' could not be found. Are you missing a using directive or an assembly reference?

with the following code

using UnityEngine;
using RestSharp;
using System;

public class Error : MonoBehaviour {

    public void callAnAPi()
    {
        var client = new RestClient();
        client.BaseUrl = new Uri("http://twitter.com");
        client.Authenticator = new RestSharp.Authenticators.HttpBasicAuthenticator("username", "password");

        var request = new RestRequest();
        request.Resource = "statuses/friends_timeline.xml";

        IRestResponse response = client.Execute(request);
        var content = response.Content;
        Debug.Log(content);
    }
}

I added RestSharp to the References and VS throws no error, only Unity does.

I read all the good replies on that error (e.g. error CS0246 missing type or namespace... - Questions & Answers - Unity Discussions and c# - Why am I getting error CS0246: The type or namespace name could not be found? - Stack Overflow), but there is no solution for me.

Thanks for help!

Adding it to the references in VS doesn’t help Unity’s compiler, unfortunately. You need to add the RestSharp.dll to your Unity project’s Assets/Plugins folder and select the appropriate platforms.