Search code examples
c#asp.netrestwebclientrestsharp

I cannot use RestSharp In my WixSharp installer, is it possible to accomplish this with HttpClient or WebClient?


private async Task<AuthenticationToken> GetToken()
    {

        string username = loginDialog.username;
        string password = loginDialog.password;
        string requestString = $"Service/Login";
        RestRequest request = new RestRequest(requestString, Method.POST);
        request.AddParameter("username", username);
        request.AddParameter("password", password);
        IRestResponse<AuthenticationToken> response = await _client.ExecuteAsync<AuthenticationToken>(request);
        return response.Data;
    }

I am using RestSharp in a few projects within my solution. I can not use it within the installer, WixSharp isn't working well with RestSharp. I need to use WebClient or HttpClient to achieve the same response as I get with this Method using the RestSharp library. Is anyone able to help?


Solution

  • In the case of requirement some external assembly for Wixsharm runtime just add it like below:

    var proj = ManagedProject()
    proj.DefaultRefAssemblies.Add("Restsharp.dll")
    

    And it will be avaliable for load in runtime and accessable for use.

    P.S. Dont forget to check assembly existence in your builder executable file output location.