现在的结构是这样的
表A,B,C
接口IA,IB,IC分别是对表A,B,C的操作
对应的实现有Aimpl,Bimpl,Cimpl
宿主是IIS,在配置文件中<wellknown mode="SingleCall" type="MySystem.impl" objectUri="Aimpl.rem"/><wellknown mode="SingleCall" type="MySystem.impl" objectUri="Bimpl.rem"/><wellknown mode="SingleCall" type="MySystem.impl" objectUri="Cimpl.rem"/>这样每加一个实现就要加一个配 置,目前已经有60左右了.现在突然说这样不好维护,要把所 有的结口改成一个,放到一个接口里.IA,IB,IC,有一些接口是 一统一的比如添加,修改等接口名称是一样的.如果要改,60个类,是很恐怖 的.而且系统可能会改出新的问题.主要问题是这个配置文件,每次有增加都要改,领导怕麻烦.试了一下用代码,反射,注册服务端,但是不行.Assembly asb = Assembly.LoadFile(strPath);
            HttpChannel channel = new HttpChannel();
            ChannelServices.RegisterChannel(channel,false);
            //反射获取类型
            Type[]tps=asb.GetExportedTypes();
            foreach (Type t in tps)
            {
                if (t.Name.Length <= 4 && t.Name.Substring(t.Name.Length - 4) != "Impl")
                    continue;
                RemotingConfiguration.RegisterWellKnownServiceType(t,t.Name + ".rem", WellKnownObjectMode.SingleCall);
            }改成这样不行,现在的客户端是通过,http://localhost/service/a.rem这样的路径来获取远程对象的,这是测试时的客户端.正式的又有版本问题http://xxxx/service1_0/a.rem   1.0版本http://xxxx/service1_3/a.rem    1.3版本有没有更好的办法?

解决方案 »

  1.   

    void Application_Start(object sender, EventArgs e) 
        {
            //在应用程序启动时运行的代码
       
            HttpChannel channel = new HttpChannel();
            ChannelServices.RegisterChannel(channel, false);
            //反射获取类型
            string strUrl = "test.rem";
            RemotingConfiguration.RegisterWellKnownServiceType(typeof(Interface.ITest), strUrl, WellKnownObjectMode.SingleCall);
               
        }
    本来想用代码来注册所有服务,但是没有成功http://www.soft000.com/down/remotingtest.rar这个是我做的测试,要不要http://localhost在服务端,都是一样的不行.如果改用配置文件就可以.帮看一下.怎么回事,要怎么改