Dynamically loading classes (with custom behavior) from different assemblies?

后端 未结 6 1080
栀梦
栀梦 2021-02-10 14:49

We are building an app for few customers, each has its own requirements along with the similar ones. We also want to keep all the code in the same app, not branch it, and the IF

6条回答
  •  逝去的感伤
    2021-02-10 15:21

    You can create an instance of an external type from an assembly this way:

    object obj = Activator.CreateInstance( 
        "External.Assembly.Name", "External.Assembly.Name.TypeName");
    BaseClass b = (BaseClass) obj;
    b.getEventId();
    

    You'd store the name of the assembly and type in your configuration file or some other appropriate place.

提交回复
热议问题