Dynamic Using/Assembly Detection.

Illelefriense

New Member
Is there a way to perform a dynamic "using" statement in C#, or detect the presence of a specific assembly? I am working on building a series of components for the web which can all tie together. Depending on the presence of the different assemblies, different options will be made available for configuration and so forth. I can't figure out for the life of me how to do this though. If I reference everything at run-time, then I can never have a new component come out, without updating all of the old ones. Any ideas?<BR><BR>Thanks,<BR>SteveYou could look at the Factory Design Pattern...<BR><BR>http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnbda/html/factopattern.asp<BR><BR>-AAfter a quick lookover, I kind of understand what they are getting at, but it seems to imply that you already know at compile time, just what will be present, and what won't be. <BR><BR>What I have in mind is more along the lines of there is one main component needed. This component is able to check the /bin directory for additional components, which may or may not be there, that it does not know about from the start. So let's say it checks the /bin folder and finds an assembly named DND.DoorParts.Frame, how can I then attempt to instantiate an instance of DND.DoorParts.Frame if it hasn't been previously referenced in the original component? Can this be done with Reflection? The user should likewise be able to drop in my latest and greatest component DND.DoorParts.Knob and be able to configure and work with it.<BR><BR>Hopefully this makes sense, because I barely understand it myself.What kind of scenario is it?<BR>Not just updating the version of a component.<BR><BR>How is the user interacting with your "newly added" components?<BR>If a new component was detected, the main administration console would instantiate the control from that assembly containing the appropriate menu options, and also enable options for other components that can interact with the new component.<BR><BR>Example:<BR>Let's say the user has a classified ad component. This component on it's own, allows people to only place ads in an anonymous fashion. If the user decides to add in the Users component, then the classifieds page would no allow the options to require that someone must be registered to place an ad. Does that make sense? That's the best example I could think of.There is something I don't get at all.<BR><BR>When I try to figure this out, I keep comming back to Interfaces and Factories.<BR><BR>What is happening? Is the user updating on of a farm of servers or is he/she visiting a web site?<BR> <BR>From the example, it seems to me that each adComponent will have a property that is a userComponent.<BR>If the user is not a registered user, his/her adComponents's will be null.<BR><BR>Can you try to describe the human process, who does what.<BR><BR>Please correct me if I'm wrong, but with Interfaces and Factories, you already know what you want to use, and what you are going to call, right?<BR><BR>Let's ignore the end user for now, and instead focus on the site admin, this is who will be most effected. The idea is that there will be one main component, we'll call this the Console. The Console is basically an administration area. The Console has a menu. If there are no other components present in the /bin directory, then there would be no menu options. <BR><BR>However, let's say the admin decided to put the component assembly: DND.Classifieds into the /bin folder, because they wanted this nifty item available on their site. The Console, when loaded up, should now detect the presence of the DND.Classifieds assembly, and reach in to create the DND.Classifieds.MenuOptions() user control, to populate the menu with this new information, so that the admin can well, admin.<BR><BR>Now at some future point in time, I develope a new component assembly, DND.News. As long as DND.News adheres to some specific rules, I should not have to change the Console, to work with DND.News, and subsequently the site admin, should not have to download a new Console. The admin should just be able to drop DND.News into the /bin directory, and the Console will detect it when loaded, and create the user control, DND.News.MenuOptions().<BR><BR>My question is, how do I make it so that Console doesn't have to be updated for each new component, but can look in the /bin directory for assemblies formatted in a specific fashion, and then implement those assemblies without ever having to have it hard coded?<BR>
 
Top