One common solution is to filter assemblies by name if all of your assemblies have a common prefix (if you have a more or less unique prefix).
var foo = AppDomain.CurrentDomain.GetAssemblies() .Where(a=>a.FullName.StartsWith("MyProject."));
If you are only interested in certain types, consider using attributes for your classes, or even add them at the assembly level.
Example:
Create an attribute:
[AttributeUsage(AttributeTargets.Assembly)] public class MyAssemblyAttribute : Attribute { }
Add the following to your AssemblyInfo.cs:
[assembly: MyAssemblyAttribute()]
and filter the assembled assemblies:
var foo = AppDomain.CurrentDomain .GetAssemblies() .Where(a => a.GetCustomAttributes(typeof(MyAssemblyAttribute), false).Any());
You will also find this question interesting. One answer suggests checking the full name of each assembly, but it is rather tedious, for example:
//add more .Net BCL names as necessary var systemNames = new HashSet<string> { "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089", "System.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" ... }; var isSystemType = systemNames.Contains(objToTest.GetType().Assembly.FullName);
It is always easier to mark assemblies (by name or attribute) than trying to determine which ones are part of the .Net framework.
sloth source share