How can I determine by reflection if the type of an object is defined by a class in my own assembly or by the .NET Framework?
I dont want to supply the name of my ow
Based on Jon's answer and Mehrdad's comment, it appears that the following three values are used for the public key token (from AssemblyName.FullName) for the .NET Framework provided assemblies from .NET 2.0 and later:
PublicKeyToken=b77a5c561934e089
PublicKeyToken=b03f5f7f11d50a3a
PublicKeyToken=31bf3856ad364e35
This was generated from the following code:
private void PrintAssemblyInfo(string fullName)
{
string[] parts = fullName.Split(',');
Console.WriteLine(" - {0}, {1}", parts[0], parts[3]);
}
private void GenerateInfo(string path)
{
foreach (var file in Directory.GetFiles(path,
"*.dll",
SearchOption.AllDirectories))
{
try
{
Assembly assembly = Assembly.ReflectionOnlyLoadFrom(file);
PrintAssemblyInfo(assembly.GetName().FullName);
}
catch { }
}
}
private void GenerateInfo()
{
GenerateInfo(@"C:\Windows\Microsoft.NET\Framework\v2.0.50727");
GenerateInfo(@"C:\Windows\Microsoft.NET\Framework\v3.0");
GenerateInfo(@"C:\Windows\Microsoft.NET\Framework\v3.5");
}