First of all, I did look into all the questions referring to the error error CS0234: The type or namespace name 'Http' does not exist in the namespace 'System.Net'(are you missing an assembly reference?) here on StackOverflow, but my case is a little different.
I have this application that uses Http requests to communicate with a Web API 2 (simple numbers, coordinates). Both applications work perfectly when run on Windows. However, for my project, I need to run the application from the terminal of Raspberry Pi 3.
I tried compiling it with Visual Studio, with and without adding MONO in the Conditional compilation symbols field. - It runs from terminal but the buttons, listboxes do not react
I compiled it in several different ways, both on windows and on Raspbian Jessie (the OS of the RPi 3):
$ **mcs -pkg:dotnet *.cs**
$ **mcs *.cs**
$ **C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe /t:exe /out:DroneApp.exe *.cs**
$ **mcs -out:hello.exe hello.cs**
$ **dmcs ./*.cs -r:/usr/lib/mono/4.0/System.Web.dll**
$ **xbuild /p:Configuration=Release DroneApp.csproj**
and any other way that I could find on the internet (I've spent 2 days doing this so I can't remember all of them). I also want to state that I installed the packages mono-devel, mono-complete, eferenceassemblies-pcl, ca-certificates-mono (which deal with Http requests) and mono-xsp4 (for ASP.net applications).
Nothing works :(
All the classes that are used as services to communicate with the server throw me the error The type or namespace name 'Http' does not exist in the namespace 'System.Net' even though I triple checked that all my references are in place.
The target framework of my app is .NET Framework 4.5.
If you have even a small idea or if I should provide some more information, please help me. Thank you.
Example of one of the service classes that throws the error (all of them are the same)
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Net.Http;
using System.Net.Http.Headers;
namespace DroneClientApp.Services
{
class PathService
{
private const string UserEndPoint = "api/Paths";
private const string RequestResponseFormat = "application/json";
private readonly string _serverUrl;
public PathService(string serverUrl)
{
_serverUrl = serverUrl;
}
public async Task<List<Path>> GetPathsAsync()
{
using (var httpClient = new HttpClient())
{
httpClient.BaseAddress = new Uri(_serverUrl);
httpClient.DefaultRequestHeaders.Accept.Clear();
httpClient.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue(RequestResponseFormat));
var response = await httpClient.GetAsync(UserEndPoint).ConfigureAwait(false);
if (response.IsSuccessStatusCode)
{
return await response.Content.ReadAsAsync<List<Path>>().ConfigureAwait(false);
}
return await Task.FromResult(new List<Path>()).ConfigureAwait(false);
}
}enter code here