Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Circular Reference Hell!

Circular Reference Hell!

Scheduled Pinned Locked Moved C#
databasetutorialquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • R Offline
    R Offline
    RFickling
    wrote on last edited by
    #1

    Hi, I am trying to use a class in multiple projects. It is a simple class containing properties of a given database table. The class, DbTable, is defined in my main DbCompare project. I also want to use this class in a Control Library (UserControl) project which will itself be used in the DbCompare project. However, I am in circular reference hell! When I build the DbCompare project, I get the warning 'DbCompare.DbTable' is defined in multiple places; using definition from 'D:\Proj_net\DbCompare\DbTable.cs'. Does anyone know how to do this? TIA, Royce

    C 1 Reply Last reply
    0
    • R RFickling

      Hi, I am trying to use a class in multiple projects. It is a simple class containing properties of a given database table. The class, DbTable, is defined in my main DbCompare project. I also want to use this class in a Control Library (UserControl) project which will itself be used in the DbCompare project. However, I am in circular reference hell! When I build the DbCompare project, I get the warning 'DbCompare.DbTable' is defined in multiple places; using definition from 'D:\Proj_net\DbCompare\DbTable.cs'. Does anyone know how to do this? TIA, Royce

      C Offline
      C Offline
      Colin Angus Mackay
      wrote on last edited by
      #2

      If you can re-architect your application I would suggest using events to avoid the circular references. If you have a layered approach like this:

       Presentation
      ----------------
       Business Logic
      ----------------
      Data Abstraction
      

      The Presentation can invoke methods directly in the Business Logic layer, and the Business Logic layer can do the same to the Data Abstraction layer. However the Data Abstraction layer should know nothing of the Business Logic layer, and the Business Logic layer should know nothing of the Presentation layer. Think about how the .NET Framework achieves this. The guys at Microsoft know nothing of your application, so the controls fire off events in order to pass messages to your code. So, If the Data Abstraction layer needs to invoke something in the Business Logic layer it should fire off an event that something in the Business Logic layer subscribes to. Similarly with the Business Logic layer needing to invoke something in the Presentation layer. Does this help?


      Do you want to know more?

      R 1 Reply Last reply
      0
      • C Colin Angus Mackay

        If you can re-architect your application I would suggest using events to avoid the circular references. If you have a layered approach like this:

         Presentation
        ----------------
         Business Logic
        ----------------
        Data Abstraction
        

        The Presentation can invoke methods directly in the Business Logic layer, and the Business Logic layer can do the same to the Data Abstraction layer. However the Data Abstraction layer should know nothing of the Business Logic layer, and the Business Logic layer should know nothing of the Presentation layer. Think about how the .NET Framework achieves this. The guys at Microsoft know nothing of your application, so the controls fire off events in order to pass messages to your code. So, If the Data Abstraction layer needs to invoke something in the Business Logic layer it should fire off an event that something in the Business Logic layer subscribes to. Similarly with the Business Logic layer needing to invoke something in the Presentation layer. Does this help?


        Do you want to know more?

        R Offline
        R Offline
        RFickling
        wrote on last edited by
        #3

        Thanks, Colin. Yes, I think you have given me some useful ideas.

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups