mganss / HtmlSanitizer

Cleans HTML to avoid XSS attacks
MIT License
1.55k stars 200 forks source link

I have updated HTMLSanitizer to 8.0.645 but getting some error like Could not load file or assembly 'AngleSharp, Version=0.17.0.0, (Exception from HRESULT: 0x80131040) #441

Closed smandlik-lab closed 1 year ago

smandlik-lab commented 1 year ago

Exception:ReflectionTypeLoadException in SerializerTypeIDCache.GetType(string name)ReflectionTypeLoadExceptionUnable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.System.Reflection.ReflectionTypeLoadException: Unable to load one or more of the requested types. Retrieve the LoaderExceptions property for more information.    at System.Reflection.RuntimeModule.GetTypes(RuntimeModule module)    at System.Reflection.Assembly.GetTypes()    at System.Linq.Enumerable.d233.MoveNext()    at System.Linq.Enumerable.WhereSelectEnumerableIterator2.MoveNext()    at System.Linq.Enumerable.d591.MoveNext()    at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable1 source)    at ScriptHelper.SerializerTypeIDCache.GetType(String name) in D:\Agents\5\inContact\CHTXRS-API\src\Code\C#\Library\ScriptHelper\AdvSerializer.cs:line 1783(Z,ZZ,&140713523177560,) 04/07/2023 06:11:49.921 (0000000B) Exception:LoaderExceptions[0]FileLoadExceptionCould not load file or assembly 'AngleSharp, Version=0.16.1.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)System.IO.FileLoadException: Could not load file or assembly 'AngleSharp, Version=0.16.1.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) File name: 'AngleSharp, Version=0.16.1.0, Culture=neutral, PublicKeyToken=e83494dcdc6d31ea'

Exception:LoaderExceptions[0]FileLoadExceptionCould 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)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) File name: 'AngleSharp, Version=0.17.0.0, Culture=neutral, PublicKeyToken=e83494dcdc6d31ea'

tiesont commented 1 year ago

How did you update?

HtmlSanitizer has (more or less) hard dependencies on what versions of AngleSharp must be used. If you manually updated the version number, you would miss the required update to AngleSharp for which the NuGet Package Manager or the NuGet CLI will prompt you.

smandlik-lab commented 1 year ago

I have updated through nuget package manager update

tiesont commented 1 year ago

Your stacktrace indicates that you have something like an app.config or web.config with an assembly binding that points to an older version (assuming this is a .NET Framework project). You'll need to update that to 0.17.0.0.

So something like this:

<runtime>
  <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">

    <dependentAssembly>
      <assemblyIdentity name="AngleSharp" publicKeyToken="e83494dcdc6d31ea" culture="neutral"/>
      <bindingRedirect oldVersion="0.0.0.0-0.16.1.0" newVersion="0.16.1.0"/>
    </dependentAssembly>

  </assemblyBinding>
</runtime>

becomes

<runtime>
  <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">

    <dependentAssembly>
      <assemblyIdentity name="AngleSharp" publicKeyToken="e83494dcdc6d31ea" culture="neutral"/>
      <bindingRedirect oldVersion="0.0.0.0-0.17.0.0" newVersion="0.17.0.0"/>
    </dependentAssembly>

  </assemblyBinding>
</runtime>

For anything else, you're really going to need to give more context. Also, please avoid posting an issue AND a question for the same problem.

mganss commented 1 year ago

Closing this for lack of feedback. Feel free to reopen with more context.