- Home /
Unity fails to load System.Net.Http script assembly
Hi, I'm working with Unity 2018.2.1f1 and I tried to use a certain function in Telegram.bot library and it gave me an error indicating that it requires an HttpClient instance as an argument.
So I imported a System.Net.Http package (v4.3.3) from NuGet and put it in the assets folder; The error went away but this other annoying error poped up that says :
Loading script assembly "Assets/Packages/System.Net.Http.dll" failed!
And the thing is that unity lets me play the game anyways and the error pretty much doesn't matter, but when I want to get a build file, it comes back and bites me in the a**. So it's pretty annoying.
"Scripting Runtime Version" and "Api Compatibility Level" is set to .Net 4.x
"Scripting Backend" is mono.
"TargetFrameworkVersion" is v4.7.1
I'm pairing vscode with unity for the record.
This is the script I'm trying to run:
using UnityEngine;
using Telegram.Bot;
using Telegram.Bot.Types;
using Telegram.Bot.Types.Enums;
using System.Net.Http;
public class TelegramSender : MonoBehaviour {
void Start () {
TelegramBotClient bot = new TelegramBotClient("<token>", new HttpClient());
bot.SendTextMessageAsync(new ChatId(<id>), "Hello World!", ParseMode.Html);
}
}
And this code actually works and sends a "Hello World!" to my telegram channel but the error just stays there and doesn't let you to get an apk.
By the way I don't think there is a Web.config or app.config file in a unity project or at least I can't find it.
Here's an image of the error:
This here looks really promising:
http://www.appzinside.com/2017/11/07/use-system-net-http-library-with-unity-in-a-hololens-app-project/