2

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

abatishchev
  • 98,240
  • 88
  • 296
  • 433
Kumar
  • 10,997
  • 13
  • 84
  • 134

3 Answers3

4

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.

Community
  • 1
  • 1
Daniel Earwicker
  • 114,894
  • 38
  • 205
  • 284
  • 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 Aug 03 '09 at 21:39
  • Check out the link to Jon's answer - he suggests trying that as well. – Daniel Earwicker Aug 03 '09 at 22:10
  • thanks, i just finished reading it, looks like that's the only way to go – Kumar Aug 03 '09 at 22:11
  • 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 Aug 04 '09 at 02:17
1

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
  • 62,489
  • 19
  • 106
  • 139
  • 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 Aug 03 '09 at 21:37
1

Here is a list based on the ECMA standard:

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

Jared Updike
  • 7,165
  • 8
  • 46
  • 72
  • Good link however it does not seem to be current or complete list e.g. system.data.datasetextensions system.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 Aug 03 '09 at 21:35
  • 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 Aug 03 '09 at 23:15