protected override string InitializeCore(DbgEvaluationContext context, DbgStackFrame frame, CancellationToken cancellationToken)
        {
            if ((evalOptions & DbgValueNodeEvaluationOptions.NoFuncEval) != 0)
            {
                return(PredefinedEvaluationErrorMessages.FuncEvalDisabled);
            }

            var proxyCtor = EnumerableDebugViewHelper.GetEnumerableDebugViewConstructor(enumerableType);

            if ((object)proxyCtor == null)
            {
                var loadState = enumerableType.AppDomain.GetOrCreateData <ForceLoadAssemblyState>();
                if (Interlocked.Exchange(ref loadState.Counter, 1) == 0)
                {
                    var loader = new ReflectionAssemblyLoader(context, frame, enumerableType.AppDomain, cancellationToken);
                    if (loader.TryLoadAssembly(GetRequiredAssemblyFullName(context.Runtime)))
                    {
                        proxyCtor = EnumerableDebugViewHelper.GetEnumerableDebugViewConstructor(enumerableType);
                    }
                }
                if ((object)proxyCtor == null)
                {
                    var asmFilename = GetRequiredAssemblyFilename(context.Runtime);
                    var asm         = enumerableType.AppDomain.GetAssembly(Path.GetFileNameWithoutExtension(asmFilename));
                    if (asm == null)
                    {
                        return(string.Format(dnSpy_Roslyn_Shared_Resources.SystemCoreDllNotLoaded, asmFilename));
                    }
                    return(string.Format(dnSpy_Roslyn_Shared_Resources.TypeDoesNotExistInAssembly, EnumerableDebugViewHelper.GetDebugViewTypeDisplayName(enumerableType), asmFilename));
                }
            }

            var runtime         = context.Runtime.GetDotNetRuntime();
            var proxyTypeResult = runtime.CreateInstance(context, frame, proxyCtor, new[] { instanceValue }, DbgDotNetInvokeOptions.None, cancellationToken);

            if (proxyTypeResult.HasError)
            {
                return(proxyTypeResult.ErrorMessage);
            }

            resultsViewProxyExpression = valueNodeProviderFactory.GetNewObjectExpression(proxyCtor, valueExpression);
            getResultsViewValue        = proxyTypeResult.Value;
            valueNodeProviderFactory.GetMemberCollections(getResultsViewValue.Type, evalOptions, out membersCollection, out _);
            return(null);
        }
        protected override string InitializeCore(DbgEvaluationContext context, DbgStackFrame frame, CancellationToken cancellationToken)
        {
            if ((evalOptions & DbgValueNodeEvaluationOptions.NoFuncEval) != 0)
            {
                return(PredefinedEvaluationErrorMessages.FuncEvalDisabled);
            }

            var proxyCtor = EnumerableDebugViewHelper.GetEnumerableDebugViewConstructor(enumerableType);

            if ((object)proxyCtor == null)
            {
                var loadState = enumerableType.AppDomain.GetOrCreateData <ForceLoadAssemblyState>();
                if (Interlocked.Increment(ref loadState.Counter) == 1)
                {
                    var loader = new ReflectionAssemblyLoader(context, frame, enumerableType.AppDomain, cancellationToken);
                    if (loader.TryLoadAssembly(GetRequiredAssemblyFullName(context.Runtime)))
                    {
                        proxyCtor = EnumerableDebugViewHelper.GetEnumerableDebugViewConstructor(enumerableType);
                    }
                }
                if ((object)proxyCtor == null)
                {
                    return(string.Format(dnSpy_Roslyn_Shared_Resources.SystemCoreDllNotLoaded, GetRequiredAssemblyFileName(context.Runtime)));
                }
            }

            var runtime         = context.Runtime.GetDotNetRuntime();
            var proxyTypeResult = runtime.CreateInstance(context, frame, proxyCtor, new[] { instanceValue }, cancellationToken);

            if (proxyTypeResult.HasError)
            {
                return(proxyTypeResult.ErrorMessage);
            }

            getResultsViewValue = proxyTypeResult.Value;
            valueNodeProviderFactory.GetMemberCollections(getResultsViewValue.Type, evalOptions, out membersCollection, out _);
            return(null);
        }
        protected override string InitializeCore(DbgEvaluationContext context, DbgStackFrame frame, CancellationToken cancellationToken)
        {
            if ((evalOptions & DbgValueNodeEvaluationOptions.NoFuncEval) != 0)
            {
                return(PredefinedEvaluationErrorMessages.FuncEvalDisabled);
            }

            var proxyCtor = EnumerableDebugViewHelper.GetEnumerableDebugViewConstructor(enumerableType);

            if ((object)proxyCtor == null)
            {
                var loadState = enumerableType.AppDomain.GetOrCreateData <ForceLoadAssemblyState>();
                if (Interlocked.Increment(ref loadState.Counter) == 1)
                {
                    //TODO: Try to force load the assembly
                    //		.NET Framework:
                    //			System.Core, Version=3.5.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
                    //			System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089
                    //		.NET Core:
                    //			v1: System.Linq, Version=4.1.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
                    //			v2: System.Linq, Version=4.2.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a
                }
                return(string.Format(dnSpy_Roslyn_Shared_Resources.SystemCoreDllNotLoaded, GetRequiredAssemblyFileName(enumerableType.AppDomain)));
            }

            var runtime         = context.Runtime.GetDotNetRuntime();
            var proxyTypeResult = runtime.CreateInstance(context, frame, proxyCtor, new[] { instanceValue }, cancellationToken);

            if (proxyTypeResult.HasError)
            {
                return(proxyTypeResult.ErrorMessage);
            }

            getResultsViewValue = proxyTypeResult.Value;
            valueNodeProviderFactory.GetMemberCollections(getResultsViewValue.Type, evalOptions, out membersCollection, out _);
            return(null);
        }