您的当前位置:首页正文

Remoting批量注册

2024-11-08 来源:个人技术集锦
		/// <summary>
        /// 注册服务
        /// </summary>
        private static void register()
        {
           
            // 注册所有继承了IRemotingService接口的类
            // 获取实现Remoting的程序集
            Assembly assembly = Assembly.GetAssembly(typeof(Remoting))
            Type[] types = assembly.GetTypes();
            Remoting.listClear();
            foreach (Type type in types)
            {
                // 继承的父类中是否包含IRemoting
                if (type.GetInterface("IRemotingService") != null && type.GetInterfaces().Length > 1)
                {
                    RemotingConfiguration.RegisterWellKnownServiceType(type, type.Name, WellKnownObjectMode.Singleton);
                }
            }
        }
显示全文