需求是这样的:
应用程序的所有菜单项名称是从一个文件如config.xml读取,每一个菜单子项对应的都是一个动态库,这个动态库名称也是从这个文件中读取.每次应用程序运行起来后就生成最新的菜单,点击相应的菜单子项就根据其对应的动态库去执行.这样,应用程序就如同一个平台,不管文件中怎样改变,这个应用程序平台不需要改变.应用程序平台及各动态库使用C#开发.
如何实现这个平台,请有经验者赐教!!

解决方案 »

  1.   

    C#
    // LoadInvoke loads MyAssembly.dll and lists the method
    // information for each method. After compiling this class,
    // run LoadInvoke.exe with the DisplayName for the assembly,
    // as shown here:
    // LoadInvoke MyAssemblyusing System;
    using System.Reflection;
    using System.Security.Permissions;public class LoadInvoke
    {
        [PermissionSetAttribute(SecurityAction.Demand, Name="FullTrust")]
        public static void Main(string[] args)
        {
            Assembly a = Assembly.Load(args[0]);
            Type[] mytypes = a.GetTypes();
            BindingFlags flags = (BindingFlags.NonPublic | BindingFlags.Public |
                BindingFlags.Static | BindingFlags.Instance | BindingFlags.DeclaredOnly);        foreach(Type t in mytypes)
            {
                MethodInfo[] mi = t.GetMethods(flags);
                Object obj = Activator.CreateInstance(t);            foreach(MethodInfo m in mi)
                {
                    // Instead of invoking the methods,
                    // it's safer to initially just list them.
                    Console.WriteLine(m);
                }
            }
        }

    C#  
    // Use this class with the LoadInvoke program.
    // Compile this class using "csc /t:library MyAssembly.cs"
    // to build MyAssembly.dll.
    using System;public class MyAssembly
    {
        public void MyMethod1()
        {
            Console.WriteLine("This is MyMethod1");
        }
        public void MyMethod2()
        {
            Console.WriteLine("This is MyMethod2");
        }
        public void MyMethod3()
        {
            Console.WriteLine("This is MyMethod3");
        }

      

  2.   

    建立若干个dll,然后加载assembly进行Method的调用
      

  3.   

    config.xml保存每个assembly的名称就可以了
      

  4.   

    谢谢大家!!
    有一个问题是如何使菜单项和相关动态库联系起来??
    += new EventHandle()
    是使用这种方法么?具体怎么处理才能响应?
      

  5.   

    你可以分析SharpDevelop的实现,不过你所说的只是他的一部分,
    http://www.icsharpcode.net/
      

  6.   

    AlphaGroup(AlphaGroup) 请问有后遗症是什么意思?会有什么问题?
    麻烦说清楚一些.