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

后端 未结 6 1007
遥遥无期
遥遥无期 2021-02-10 14:36

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:15

    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.

提交回复
热议问题