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 dependency solution?

Circular dependency solution?

Scheduled Pinned Locked Moved C#
csharpvisual-studioquestion
4 Posts 3 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.
  • A Offline
    A Offline
    Alex Korchemniy
    wrote on last edited by
    #1

    I have a main application that is referenced by a plugin. I would like the plugin assembly to be copied into the main application folder. Currently I have to do it manually because VS.net will not allow me to add a circular dependency. Any solutions?

    H 1 Reply Last reply
    0
    • A Alex Korchemniy

      I have a main application that is referenced by a plugin. I would like the plugin assembly to be copied into the main application folder. Currently I have to do it manually because VS.net will not allow me to add a circular dependency. Any solutions?

      H Offline
      H Offline
      Heath Stewart
      wrote on last edited by
      #2

      The solution is a simple logical solution: a plugin should typically not have a dependency on the application that hosts it, but perhaps a shared assembly that the application uses. Having the plugin depend on the application itself makes your design very inflexible. Worse yet, never have a dependency on your plugin. The whole idea of plugins is that they can be added or removed from your application (either before executing it or while executing it) without the application knowing about it. This is where polymorphism comes into play. You either use interfaces or abstract classes declared in a shared assembly that plugins reference. They extend the abstract class and/or implement the required interfaces. Your application communicates with the plugins through these classes or interfaces without knowledge of the actual implementation. This is the entire fundation of COM, .NET (a progression of COM, but not a replacement), web services, and many other technologies. All communication is done through a common interface (also called a "contract") so that the implementation is hidden. That's a true plugin. These plugins could be loaded from the .config file (common in .NET applications), some other file or the registry (which COM uses, but is not recommended for .NET code for deployment reasons), or even enumerated in a directory and loaded. There are many articles here on CodeProject that discuss various implementations of plug-in system. Just try a search for "plug-ins" or something similar.

      Microsoft MVP, Visual C# My Articles

      A 1 Reply Last reply
      0
      • H Heath Stewart

        The solution is a simple logical solution: a plugin should typically not have a dependency on the application that hosts it, but perhaps a shared assembly that the application uses. Having the plugin depend on the application itself makes your design very inflexible. Worse yet, never have a dependency on your plugin. The whole idea of plugins is that they can be added or removed from your application (either before executing it or while executing it) without the application knowing about it. This is where polymorphism comes into play. You either use interfaces or abstract classes declared in a shared assembly that plugins reference. They extend the abstract class and/or implement the required interfaces. Your application communicates with the plugins through these classes or interfaces without knowledge of the actual implementation. This is the entire fundation of COM, .NET (a progression of COM, but not a replacement), web services, and many other technologies. All communication is done through a common interface (also called a "contract") so that the implementation is hidden. That's a true plugin. These plugins could be loaded from the .config file (common in .NET applications), some other file or the registry (which COM uses, but is not recommended for .NET code for deployment reasons), or even enumerated in a directory and loaded. There are many articles here on CodeProject that discuss various implementations of plug-in system. Just try a search for "plug-ins" or something similar.

        Microsoft MVP, Visual C# My Articles

        A Offline
        A Offline
        Alex Korchemniy
        wrote on last edited by
        #3

        I understand all of that. It's just the way I worded it. My solution: create an xml files that holds the plugins currently in use. For plugin paths just use the existing file structure without copying the files to the local directory. I admit I should not have been working for the 18 hour that day.

        A 1 Reply Last reply
        0
        • A Alex Korchemniy

          I understand all of that. It's just the way I worded it. My solution: create an xml files that holds the plugins currently in use. For plugin paths just use the existing file structure without copying the files to the local directory. I admit I should not have been working for the 18 hour that day.

          A Offline
          A Offline
          Andy Wieberneit
          wrote on last edited by
          #4

          Why not have the plugin simply implement a delegate/event? The main application would add a handler for that event. Each time the event is caught, the main app could make a call into the plugin. Hence the plugin would initiate a call from the main app.

          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