0
Working on Fix

InvalidCastException Upon Extraction Bolt 2.0.5

Marshall Brooks 2 months ago • updated by Lazlo Bonin (Lead Developer) 2 months ago 3

On extraction of Unit Options, while it completes successfully, it throws the following exception:

InvalidCastException: Specified cast is not valid. Rethrow as AggregateException: One or more errors occured.

Stack trace is as follows:

[Exception] InvalidCastException: Specified cast is not valid.
Rethrow as AggregateException: One or more errors occurred.
Assembly.Equals() <1f0c1ef1ad524c38bbc5536809c46b48>:0

System.Collections.Generic.ObjectEqualityComparer`1[T].Equals() <1f0c1ef1ad524c38bbc5536809c46b48>:0

System.Collections.Generic.Dictionary`2[TKey,TValue].FindEntry() <1f0c1ef1ad524c38bbc5536809c46b48>:0

System.Collections.Generic.Dictionary`2[TKey,TValue].TryGetValue() <1f0c1ef1ad524c38bbc5536809c46b48>:0

AttributeUtility.GetAttributeCache() Assets/Ludiq/Ludiq.Core/Runtime/Reflection/AttributeUtility.cs:347

AttributeUtility.HasAttribute[TAttribute]() Assets/Ludiq/Ludiq.Core/Runtime/Reflection/AttributeUtility.cs:438

MemberFilter.ValidateMember() Assets/Ludiq/Ludiq.Core/Runtime/Reflection/MemberFilter.cs:497

CodebaseSubset+<>c__DisplayClass25_0.b__2() Assets/Ludiq/Ludiq.Core/Editor/Reflection/CodebaseSubset.cs:76

System.Linq.Enumerable+WhereSelectArrayIterator`2[TSource,TResult].MoveNext() <3e4da02cf86b4fc686ed0ac61bffc210>:0

CodebaseSubset+d__25.MoveNext() Assets/Ludiq/Ludiq.Core/Editor/Reflection/CodebaseSubset.cs:75

Ludiq.TaskLinq+<>c__DisplayClass3_2`2[TSource,TResult].b__1() Assets/Ludiq/Ludiq.Core/Editor/Tasks/TaskLinq.cs:71

System.Threading.Tasks.Parallel+<>c__DisplayClass42_0`2[TSource,TLocal].b__1() <1f0c1ef1ad524c38bbc5536809c46b48>:0

Task.InnerInvoke() <1f0c1ef1ad524c38bbc5536809c46b48>:0

Task.InnerInvokeWithArg() <1f0c1ef1ad524c38bbc5536809c46b48>:0

Task+<>c__DisplayClass178_0.b__0() <1f0c1ef1ad524c38bbc5536809c46b48>:0

Task.ThrowIfExceptional() <1f0c1ef1ad524c38bbc5536809c46b48>:0

Task.Wait() <1f0c1ef1ad524c38bbc5536809c46b48>:0

Task.Wait() <1f0c1ef1ad524c38bbc5536809c46b48>:0

Parallel.PartitionerForEachWorker[TSource,TLocal]() <1f0c1ef1ad524c38bbc5536809c46b48>:0

Parallel.ForEach[TSource]() <1f0c1ef1ad524c38bbc5536809c46b48>:0

Ludiq.TaskLinq+<>c__DisplayClass3_0`2[TSource,TResult].b__0() Assets/Ludiq/Ludiq.Core/Editor/Tasks/TaskLinq.cs:67

Task.Run() Assets/Ludiq/Ludiq.Core/Editor/Tasks/Task.cs:65

WindowTaskRunner.RunSynchronous() Assets/Ludiq/Ludiq.Core/Editor/Tasks/Runners/WindowTaskRunner.cs:61

Debug.LogException()

WindowTaskRunner.RunSynchronous() Assets/Ludiq/Ludiq.Core/Editor/Tasks/Runners/WindowTaskRunner.cs:67

WindowTaskRunner.Run() Assets/Ludiq/Ludiq.Core/Editor/Tasks/Runners/WindowTaskRunner.cs:44

Task.Run() Assets/Ludiq/Ludiq.Core/Editor/Tasks/Task.cs:194

TaskLinq.SelectManyTask() Assets/Ludiq/Ludiq.Core/Editor/Tasks/TaskLinq.cs:61

CodebaseSubset.Filter() Assets/Ludiq/Ludiq.Core/Editor/Reflection/CodebaseSubset.cs:45

Ludiq.CodebaseSubset..ctor() Assets/Ludiq/Ludiq.Core/Editor/Reflection/CodebaseSubset.cs:32

Codebase.Subset() Assets/Ludiq/Ludiq.Core/Editor/Reflection/Codebase.cs:328

Ludiq.Bolt.<>c__DisplayClass12_0.b__0() Assets/Ludiq/Bolt.Flow/Editor/Options/UnitOptionsExtractor.cs:70

Task.Run() Assets/Ludiq/Ludiq.Core/Editor/Tasks/Task.cs:65

WindowTaskRunner.RunSynchronous() Assets/Ludiq/Ludiq.Core/Editor/Tasks/Runners/WindowTaskRunner.cs:61

WindowTaskRunner.Run() Assets/Ludiq/Ludiq.Core/Editor/Tasks/Runners/WindowTaskRunner.cs:44

Task.Run() Assets/Ludiq/Ludiq.Core/Editor/Tasks/Task.cs:194

UnitOptionsExtractor.ExtractFull() Assets/Ludiq/Bolt.Flow/Editor/Options/UnitOptionsExtractor.cs:67

UnitOptionsExtractor.Extract() Assets/Ludiq/Bolt.Flow/Editor/Options/UnitOptionsExtractor.cs:53

Ludiq.Bolt.<>c__DisplayClass19_0.b__0() Assets/Ludiq/Bolt.Core/Editor/Extraction/Extraction.cs:88

Task.Run() Assets/Ludiq/Ludiq.Core/Editor/Tasks/Task.cs:65

WindowTaskRunner.RunSynchronous() Assets/Ludiq/Ludiq.Core/Editor/Tasks/Runners/WindowTaskRunner.cs:61

Ludiq.<>c__DisplayClass10_0.b__0() Assets/Ludiq/Ludiq.Core/Editor/Tasks/Runners/WindowTaskRunner.cs:33

ThreadHelper.ThreadStart()

Bolt Version:
2.0.5
Unity Version:
2019.1.1f1 (Also occurs in 2018.3)
.NET Version:
4.0
Bolt 2
Under Review

Hi Marshall, thanks for the report.

I can't get this to reproduce. Are you using any third party assets that may be related? Are you getting this error in an empty project with just Bolt?

+1
Working on Fix

I got the error randomly too in 2018.4.0f1. Seems like something related to a bug in the .NET runtime itself. I'm attempting a fix.

I haven't had the chance to extensively test this, but the temporary fix seems to work. Replace line 11 in AtributeUtility.cs with:

private static readonly Dictionary<object, AttributeCache> optimizedCaches = new Dictionary<object, AttributeCache>(ReferenceEqualityComparer.Instance);