Circular references in .Net framework?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Dansk

    #1

    Circular references in .Net framework?

    Hi all,

    I am currently writing some code that explores assemblies dependencies.

    I start loading the first assembly with Assmebly.LoadFr om which gives me
    an Assembly instance.

    Then, I enumerate the AssemblyNames from the GetReferencedAs semblies()
    collection.

    And foreach AssemblyName in that collection, I call again Assembly.Load.

    .... and so on recursively...

    The first run made a call stack overflow.

    After debugging a bit, I discovered that Assembly System.dll has a
    dependency on System.Xml.dll, which has itself a dependency on System.dll.

    The first and the second system.dll are at the same location (the GAC)

    System.Xml.dll is also in the GAC.

    Where am I wrong?


    Thanks in advance,
    Dansk.
  • Marc Gravell

    #2
    Re: Circular references in .Net framework?

    That sounds about right...

    There are a few circular references in the base libraries... not a
    good idea for regular code, but arguably necessary in some scenarios.
    You can't create a circular reference via the IDE - you have to use
    the command line libraries and a lot of trouble.

    The trick is (when walking references) to keep a track of things you
    have visited, and stop when you see them again.

    Marc

    Comment

    • Dansk

      #3
      Re: Circular references in .Net framework?


      Well... ok.
      Thank you for the info, then, even if I find it a bit odd...

      Don't worry, I won't even have the idea to try having circular
      references in my projects! :)

      Thanks again.
      Dansk

      Marc Gravell wrote:
      That sounds about right...
      >
      There are a few circular references in the base libraries... not a
      good idea for regular code, but arguably necessary in some scenarios.
      You can't create a circular reference via the IDE - you have to use
      the command line libraries and a lot of trouble.
      >
      The trick is (when walking references) to keep a track of things you
      have visited, and stop when you see them again.
      >
      Marc

      Comment

      Working...