GAC and assembly types

  • Thread starter Thread starter Paul K
  • Start date Start date
P

Paul K

I have a base interface named IBase. Two classes,
CChild1 and CChild2 implement IBase. CChild1 and CChild2
perform the same function but in different ways.

My client application needs to be able to choose either
CChild1 or CChild2 at runtime and create an object of the
class.

I haven't found any way to scan the GAC to see which
assemblies contain components which implement IBase.
Could anyone help me with this?

Paul K
 
Are you sure you want to scan the entire GAC to find one assembly that
contains your classes (this would NOT be a fast process)?

A better way to do it would be to encapsulate the creation of those class in
some factory pattern. Then, in app.config, you would register the
assemblies and types that implement the interface. These would then be
loaded by your factory structure and be given to your application based on
some defined criteria.

Or you could just hardcode the construction in your application, but the
above makes it more flexible as you can add more classes without modifying
your application.
 
Back
Top