Failed to compare two elements in the array. - Monotorrent v3.0.0-beta.rev0102
See original GitHub issueSystem.InvalidOperationException
Message : Failed to compare two elements in the array.
StackTrace : at System.Collections.Generic.GenericArraySortHelper`1.BinarySearch(T[] array, Int32 index, Int32 length, T value, IComparer`1 comparer)
at System.Array.BinarySearch[T](T[] array, Int32 index, Int32 length, T value, IComparer`1 comparer)
at System.Collections.Generic.SortedList`2.Add(TKey key, TValue value)
at MonoTorrent.BEncoding.BEncodeDecoder.DecodeTorrent(Stream reader)
at MonoTorrent.Torrent.Load(Stream stream, ReadOnlySpan`1 buffer)
at MonoTorrent.Torrent.Load(String path)
at MultiUploader.Helpers.Torrents.IsImageFromTorrent(String torrentFile)
System.BadImageFormatException
Message : Could not load file or assembly 'System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' or one of its dependencies. Reference assemblies should not be loaded for execution. They can only be loaded in the Reflection-only loader context. (Exception from HRESULT: 0x80131058)
StackTrace : at System.ReadOnlyMemory`1.get_Span()
at MonoTorrent.BEncoding.BEncodedString.CompareTo(BEncodedString other)
at System.Collections.Generic.GenericArraySortHelper`1.BinarySearch(T[] array, Int32 index, Int32 length, T value)
at System.Collections.Generic.GenericArraySortHelper`1.BinarySearch(T[] array, Int32 index, Int32 length, T value, IComparer`1 comparer)
System.BadImageFormatException
Message : Cannot load a reference assembly for execution.
My Code is:
foreach (TorrentFile file in Torrent.Load(torrentFile)) {
if (Regex.IsMatch(file.Path, "^.*\.(iso|cue)$", RegexOptions.IgnoreCase)) {
return true;
}
}
}
return false;
Issue Analytics
- State:
- Created 9 months ago
- Comments:24 (14 by maintainers)
Top Results From Across the Web
Failed to compare two elements in the array
My objects don't implement IComarable or IComparable at all and they still work fine. I am creating a CollectionViewSource and adding sort ...
Read more >error LGHT0001: Failed to compare two elements in the ...
The linker on v4.0.2220.0 throws this error: light.exe(0,0): error LGHT0001: Failed to compare two elements in the array. The bug did not exist...
Read more >“Failed to compare two elements in the array” Error During ...
I've made a custom SPExport and SPImport tool that duplicates site content around the SharePoint site collection. However, it would suddenly ...
Read more >Failed to compare two elements in the array. in UI for ...
This only happens when I try to adda new activity to the grid when it is sorted. When the Grid is not sorted,...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I can definitely see the
ref
assembly listed here… but that shouldn’t happen 😦@alanmcgovern @foxi69 I tried this scenario using the supplied project in TestAppInstaller.zip, and in my testing I found that both workarounds fix the issue where reference assemblies are taken from NuGet packages. Here’s what I did:
%NugetCachePath%\system.buffers\4.5.1*ref*\net45\System.Buffers.dll %NugetCachePath%\system.drawing.common\5.0.3*ref*\net461\System.Drawing.Common.dll %NugetCachePath%\system.numerics.vectors\4.5.0*ref*\net46\System.Numerics.Vectors.dll %NugetCachePath%\system.runtime.compilerservices.unsafe\4.5.3*ref*\net461\System.Runtime.CompilerServices.Unsafe.dll %NugetCachePath%\system.security.principal.windows\4.0.0*ref*\net46\System.Security.Principal.Windows.dll %NugetCachePath%\system.valuetuple\4.5.0*ref*\net47\System.ValueTuple.dll
TesterApp\packages\System.Buffers.4.5.1*lib*\net461\System.Buffers.dll TesterApp\packages\System.Drawing.Common.5.0.3*lib*\net461\System.Drawing.Common.dll TesterApp\packages\System.Numerics.Vectors.4.5.0*lib*\net46\System.Numerics.Vectors.dll TesterApp\packages\System.Runtime.CompilerServices.Unsafe.4.5.3*lib*\net461\System.Runtime.CompilerServices.Unsafe.dll TesterApp\packages\System.Security.Principal.Windows.4.0.0*lib*\net46\System.Security.Principal.Windows.dll TesterApp\packages\System.ValueTuple.4.5.0*lib*\net47\System.ValueTuple.dll
%NugetCachePath%\system.buffers\4.5.1\lib\net461\System.Buffers.dll %NugetCachePath%\system.drawing.common\5.0.3\lib\net461\System.Drawing.Common.dll %NugetCachePath%\system.numerics.vectors\4.5.0\lib\net46\System.Numerics.Vectors.dll %NugetCachePath%\system.runtime.compilerservices.unsafe\4.5.3\lib\net461\System.Runtime.CompilerServices.Unsafe.dll %NugetCachePath%\system.security.principal.windows\4.0.0\runtimes\win\lib\net46\System.Security.Principal.Windows.dll %NugetCachePath%\system.valuetuple\4.5.0\lib\net47\System.ValueTuple.dll
So, while I can’t confirm this makes the app work, I do think it’s worth revisiting these workarounds (specifically the much simpler one explained in 3 above) and taking a closer look at what’s failing.
A couple notes: