确定是否装配是.NET框架的一部分框架、NET

2023-09-04 02:05:11 作者:动我女人你想死得早了么?

如何,我可以告诉从组件的名称,或装配类(或其他类似的),一个集是否是的。NET 框架(即 System.Windows.Forms的)?

How can I tell from the assembly name, or assembly class (or others like it), whether an assembly is part of the .NET framework (that is, System.windows.Forms)?

到目前为止,我已经考虑了公钥和codeBase的特性,但这些并不总是相同的整体框架。

So far I've considered the PublicKeyToken, and CodeBase properties, but these are not always the same for the whole framework.

我希望这个信息的原因是为了让我的EXE文件正在使用需要在客户机程序集的列表,所以我不使用Visual Studio安装系统可以打包在一个安装文件正确的文件。问题是,我不想拿起任何.NET Framework程序集,我希望它是一个自动的过程,很容易推出每当有重大的更新完成。

The reason I want this information is to get a list of assemblies that my EXE file is using that need to be on client machines, so I can package the correct files in a setup file without using the Visual Studio setup system. The problem is, I don't want to pick up any .NET framework assemblies, and I want it to be an automatic process that is easy to roll out whenever a major update is finished.

最终的解决办法是,有一个IsFramework属性...:)

The ultimate solution would be that there is an IsFramework property... :)

推荐答案

我怀疑是这两种方法最可靠,最普遍的是将是公钥。是的,有一个以上的,但它会是一个有限的列表,一个不经常变化。

I suspect that the method both most reliable and most general is going to be the PublicKeyToken. Yes, there's more than one, but it's going to be a finite list and one that doesn't change very often.

对于这个问题,你可以只是组装名字的白名单 - 该名单,也将是双方有限的,静态的框架版本之间

For that matter, you could just have a whitelist of assembly names -- that list, too, will be both finite and static between versions of the framework.