Fog Creek Software
Discussion Board




Welcome! and rules

Joel on Software

.Net equivalent to ProgID

Here's a situation and the way I would handle something in COM/ActiveX.  My question is what is the .net equivalent.

I have an Interface
  ICustomerAction
      DoFunctionA
      DoFunctionF

I implement this interface for the generic (typical) case.  So I end up with the interface implemented in a DLL ("Action.dll") and the implemented interface has a ProgID "Action.Default".

I then implement this interface for 2 different customers (the other 10 use the default) .  I give CustomerA a dll ("ActionA.dll") and the progid is "Action.CustomerA" (B gets ActionB.dll/Action.CustomerB). 

So basically all customers have "Action.dll" and possibly "Action[CustomerName].dll".  My main code then does the following when it needs to execute something on the action interface:
    1) Try to get the classid from progid looking for customer specific name- CLSIDFromProgID("Action.[CustomerName]")
    2) If this fails, get the base implementation -CLSIDFromProgID("Action.Default")
    3) Execute the function on proper interface

So in .net, I would create an interface for IAction.  I would implement the differnt classes that implement IAction but how do I mimic this dynamic loading based on whether the customer specific dll is present?

MikeG
Tuesday, February 01, 2005

Look into the reflection APIs ... you can do a LoadAssembly based on the customer name and then try to create an instance to a specifc type.

If that fails fall back on the default.

Rob Walker
Tuesday, February 01, 2005

Activator.CreateInstance

Dennis Forbes
Wednesday, February 02, 2005

*  Recent Topics

*  Fog Creek Home