C# 如何获取AppDomain中的所有非.NET framework程序集?

C# 如何获取AppDomain中的所有非.NET framework程序集?,c#,.net,.net-assembly,appdomain,C#,.net,.net Assembly,Appdomain,我正在尝试查找当前AppDomain中的所有程序集,它们不是.NET framework的一部分(这意味着它们是我自己的库或第三方库) 有没有比将.NET Framework的所有程序集名称硬编码到我的代码中并从AppDomain.CurrentDomain.GetAssemblies()中查找所有与之不匹配的程序集更简单的方法 String[] dotNetPaths=new string[]{"/Windows/Microsoft.Net/assembly/","/Windows/Micro

我正在尝试查找当前AppDomain中的所有程序集,它们不是.NET framework的一部分(这意味着它们是我自己的库或第三方库)

有没有比将.NET Framework的所有程序集名称硬编码到我的代码中并从
AppDomain.CurrentDomain.GetAssemblies()
中查找所有与之不匹配的程序集更简单的方法

String[] dotNetPaths=new string[]{"/Windows/Microsoft.Net/assembly/","/Windows/Microsoft.NET/Framework/"};
var otherAssemblies=AppDomain.CurrentDomain
                             .GetAssemblies()
                             .Where(x=>!dotNetPaths.Any(y=>x.CodeBase.Contains(y)));
价值将是Microsoft®.NET Framework


价值将是Microsoft®.NET Framework

谢谢,这是一个很棒的解决方案!如果有人给出更好的答案,我还是会等待,但如果没有,我会接受!另外:有些程序集的值为“Microsoft®Visual Studio”,但我确信只有在将调试器附加到进程时才会发生这种情况。对于某些程序集,属性将为“Microsoft ASP.NET Core MVC”或“Microsoft.NET Extensions”或“Microsoft ASP.NET Core”,因此我们可以排除以“Microsoft”开头的程序集。谢谢,这是一个伟大的解决方案!如果有人给出更好的答案,我还是会等待,但如果没有,我会接受!另外:某些程序集的值为“Microsoft®Visual Studio”,但我确信只有在将调试器附加到进程时才会发生这种情况。对于某些程序集,属性将为“Microsoft ASP.NET Core MVC”或“Microsoft.NET Extensions”或“Microsoft ASP.NET Core”,因此我们可以排除以“Microsoft”开头的程序集
        Assembly a = Assembly.GetAssembly(typeof(Task));
        CustomAttributeData attributeData = a.CustomAttributes.First(attribute => attribute.AttributeType == typeof(AssemblyProductAttribute));
        string value = attributeData.ConstructorArguments[0].Value as string;