views:

134

answers:

1

I was writing some C# code recursively walking the referenced assemblies of a base assembly, building up a directed acyclic graph of these references to do a topological sort. I'm doing this by means of the GetReferencedAssemblies() method on the Assembly class.

While testing the code, I found - to my surprise - that some assemblies in the .NET framework apparently list themselves as assembly references. One such example is System.Transactions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 which lists System.Transactions, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 as a reference, as can be verified in Reflector.

Once I realized this, it was trivial to break the infinite recursion by comparing the AssemblyNames, but I am curious about the situation since I was not able to generate a self recursive assembly myself. (I can Google no information on this and adding myself as a reference does not make the resulting assembly self recursive.)

In short: are self recursive assembly references really "kosher" - what would the rationale for a few of the system assemblies to reference themselves be?

Thanks.

+3  A: 

A question was asked yesterday entitled How did Microsoft create assemblies that have circular references? that might explain more about how this is done. I cannot think of a valid reason for an assembly to have a reference to itself though.

adrianbanks
Thanks for the pointer, somehow I missed that post.
Cumbayah