Get the topmost assembly name
This is just a useful snippet that will get you the top most assembly name. Especially useful if you have code in a NuGet package that will be consumed by some other library… and eventually by an application.
public string GetTopLevelAssembly() { StackFrame[] stackTraceFrames = new StackTrace().GetFrames(); return stackTraceFrames .Select(f => f.GetMethod().ReflectedType.AssemblyQualifiedName) .Distinct() .Last(); }
Written by Steve Fenton on