tags:

views:

111

answers:

3

Is there a preferred way to identify core .net framework assemblies ? i.e. asm which are part of the framework ?

This is for a an application auto updater which

1) takes in an assembly using ASP.NET upload

2) checks it's assembly references

3) ensures they're available for deployment too

4) they're pulled as needed based on auth/authorization etc. etc

Part #3 is where it'd be good to check if they're part of the core framework

+1  A: 

You can check the property Assembly.GlobalAssemblyCache to see if it's in the GAC, but I think that's the closest you can get without parsing Microsoft's name from the assembly company.

John Rasch
since custom dll's can go into the gac, that's not a reliable indicator, if nothing else then will parse the microsoft name from the asm co.
Kumar
+3  A: 

Assemblies have attributes that you can examine with reflection:

 object[] attribs = assembly.GetCustomAttributes();

You could take a look at the objects returned by that call in the debugger, and see if any are common across the assemblies you want to categorise.

Edit: And - what a surprise! - Jon Skeet has already posted an answer to a similar-but-not-identical question using this technique. Should work for you as well.

Daniel Earwicker
looks interesting, however i'd think it'd be preferable to use a list of public key's to match since someone can put in the Microsoft string by omission or commission as they say
Kumar
Check out the link to Jon's answer - he suggests trying that as well.
Daniel Earwicker
thanks, i just finished reading it, looks like that's the only way to go
Kumar
I just added a follow-up (http://stackoverflow.com/questions/962639/detect-if-the-type-of-an-object-is-a-type-defined-by-net-framework/1225438#1225438) to Jon's response in the above mentioned question which shows the different public key tokens used by the different assemblies.
Scott Dorman
+1  A: 

Here is a list based on the ECMA standard:

http://en.wikipedia.org/wiki/Base_Class_Library

Jared Updike
Good linkhowever it does not seem to be current or complete liste.g. system.data.datasetextensionssystem.data.datavisualization etc.In any event, i'd think it'd be preferable to do a match on say the publicKey instead which would be far fewer than the namespaces or names themselves
Kumar
Good point. I'm just glad to see that there is a proper name for "the core framework assemblies": BCL or Base Class Library.
Jared Updike