private static IEnumerable GetAssembliesInSingleException()

in Managed/Util/ExceptionHelper.cs [40:61]


        private static IEnumerable<Assembly> GetAssembliesInSingleException(Exception exception)
        {
            // some exceptions (like AggregateException) don't have an associated stacktrace
            if (exception != null && exception.StackTrace != null)
            {
                StackTrace stackTrace = new StackTrace(exception, false);
                foreach (StackFrame frame in stackTrace.GetFrames())
                {
                    // DeclaringType can be null for lambdas created by Reflection.Emit
                    Type declaringType = frame.GetMethod().DeclaringType;
                    if (declaringType != null)
                    {
                        Assembly currentAssembly = declaringType.Assembly;
                        Debug.Assert(currentAssembly != null, "currentAssembly must not be null");
                        if (currentAssembly != null)
                        {
                            yield return currentAssembly;
                        }
                    }
                }
            }
        }