(Impossible) HtmlAgilityPack not found in Unity

html-agility-pack unity3d


I have a problem with the HtmlAgilityPack...
I have correctly imported the pack in Visual Studio (References > Manage NuGet Packages > Browse, and just installed the package)
In Unity I get this error:

Assets/Scripts/Searcher.cs(13,7): error CS0246: The type or namespace name 'HtmlAgilityPack' could not be found. Are you missing an assembly reference?

I didn't forgot two add using HtmlAgilityPack; in my script

Using ? :
- Unity 2017.2.1f1
- Microsoft Visual Studio Community 2015
- HtmlAgilityPack 1.6.13

2/2/2018 5:09:09 PM

Accepted Answer

Based on a similar question over on Unity Answers:

Unity itself is incapable of handling Nuget packages, they're more of a VS thing. But as long as the assembly targets .NET 2.0 you should be able to use the .dll in Unity without issue

I can't find any information on what version of .NET that HtmlAgilityPack targets, but my guess is that it isn't the same as what Unity uses. By default Unity 2017 uses the .NET 3.5 runtime with an option to switch to the experimental 4.6 runtime.

The best compatibility will be with both targetting the same version, but in the case of it differing, Unity will need to be newer as if the dll uses features added by (say) .NET 4.6 and Unity's set to use .NET 3.5, Unity won't be able to handle those calls.

Try changing to the .NET 4.6 experimental runtime and seeing if that works.

Under Edit -> Project -> Player:


1/12/2018 5:47:36 PM

Popular Answer

Not sure why this was marked impossible. You can do this by simply dropping HTMLAgilityPack.dll into Unity. Unity will recognize the library and make it available in VS2017.

Here's what it looks like in Unity when imported correctly.

I am on (Experimental .Net 4.6), but I doubt that makes a difference.

Related Questions


Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow
Licensed under: CC-BY-SA with attribution
Not affiliated with Stack Overflow