mganss / HtmlSanitizer

Cleans HTML to avoid XSS attacks
MIT License
1.51k stars 198 forks source link

AngleSharp missing dependency #528

Closed Chmielinski closed 4 months ago

Chmielinski commented 4 months ago

Hi all,

Having an issue after installing HtmlSanitizer 8.0.838 (latest version on NuGet). Just trying to use the default constructor throws the following error during runtime:

System.TypeInitializationException: The type initializer for 'Ganss.Xss.HtmlSanitizer' threw an exception. ---> System.IO.FileLoadException: Could not load file or assembly 'AngleSharp, Version=0.17.0.0, Culture=neutral, PublicKeyToken=e83494dcdc6d31ea' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)

Which is weird considering AngleSharp is listed at 0.17.1 in the HtmlSanitizer NuGet package info. I tried installing AngleSharp 0.17.0 manually, but it wouldn't let me due to that HtmlSanitizer dependency. I also tried doing a binding redirect, but that was no help either.

mganss commented 4 months ago

This looks similar to #442. Have you tried deleting the .vs, bin, and obj folders? Can you repro in a fresh console application?

Chmielinski commented 4 months ago

Looks like there was an out-of-date binding redirect for AngleSharp that was causing the issue.