Alex Rivera | Logout

Determining if an assembly is part of the .NET framework

Asked 2008-09-09T15:18:14.583
20

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)?

So far I've considered the PublicKeyToken, and CodeBase properties, but these are not always the same for the whole 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.

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

Edit
Report

2 Answers

2

If you know that none of your DLLs will be in the GAC you could check whether each assembly is in the GAC or not. If it is, don't copy it. If it isn't, then do copy it. There is a property on the Assembly class called GlobalAssemblyCache. This would obviously work better in some situations than in others.

answered 2010-01-06T00:02:33.027
2

When you install Visual Studio, you get the reference assemblies in various subfolders of the form C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\{FrameworkName}\{FrameworkVersion} - the most interesting thing could be the RedistList\FrameworkList.xml file that contains a list of all assembly names that were shipped with the given framework version.

E.g. C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\RedistList\FrameworkList.xml seems to contain a list of all of .NET 4.0's Framework assemblies.

You could easily use these files to establish static white lists of assemblies.

answered 2013-01-28T09:08:33.057

Your Answer