从用户控件中动态加载程序集

Assembly assembly = null;
string windowsPath = Path.Combine(Application.StartupPath, "Windows");
 
foreach (string dllFile in Directory.GetFiles(windowsPath, "*.dll"))
{
     assembly = Assembly.LoadFile(dllFile);
     Type[] types = assembly.GetTypes();
     foreach (Type t in types)
     {
          //增加你的代码
     }
}

结合DesigerHost可以实现类似VS动态加载控件

 

posted @ 2020-07-22 22:44  zhaogaojian  阅读(153)  评论(0编辑  收藏  举报