开发者

Any way to check if an assembly is a framework assembly, in .Net, other than checking the name for 'System'?

Since, it开发者_如何学编程's possible for anyone to name an assembly starting with 'System', checking for 'System' is not a satisfactory solution.

Alternatively, if that's not possible, how about checking the modules in an assembly?


All .NET assemblies might have the same public key token: b77a5c561934e089


It is a moving target. For example, the PrintForm component wasn't originally part of the framework install set, but it is in .NET 3.5 SP1. The very best thing to do is to not ask the question, you'll get in trouble some day when you do.


If you're not too concerned with security then you could simply check the path

Console.WriteLine(typeof(File).Assembly.Location.EndsWith(@"Microsoft.NET\Framework64\v2.0.50727\mscorlib.dll"));

Otherwise, as already suggested, the public key token on the fullname would be safest:

Console.WriteLine(typeof(File).Assembly.FullName.Contains("PublicKeyToken=b77a5c561934e089"));
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜