Pergunta

I am trying to find all assemblies in the current AppDomain, which are not part of the .NET framework (which means that they are either my own libraries or 3rd party libraries).

Is there any easier way to do it than hard-coding all the .NET Framework's assemblies names to my code and finding all Assemblies from AppDomain.CurrentDomain.GetAssemblies() which doesn't match any of them?

Foi útil?

Solução

        Assembly a = Assembly.GetAssembly(typeof(Task));
        CustomAttributeData attributeData = a.CustomAttributes.First(attribute => attribute.AttributeType == typeof(AssemblyProductAttribute));
        string value = attributeData.ConstructorArguments[0].Value as string;

And the value will be Microsoft® .NET Framework

Outras dicas

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)));
Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top