代码如下:
    public void StartServer()
        {
            
            TcpServerChannel channel = new TcpServerChannel(9000);
            ChannelServices.RegisterChannel(channel, false);
            ChannelServices.UnregisterChannel(channel);
            RemotingConfiguration.RegisterWellKnownServiceType(typeof(SmartKernel.Net.Monitor), "MonitorServerUrl", WellKnownObjectMode.Singleton);
           }启动程序后CPU占用80%,但使用另一台计算机却正常,这是为什么呢?

解决方案 »

  1.   

    remoting它的序列化和反序列化大量的使用了反射技术
    以前就有人抱怨过
    相关讨论
      

  2.   

    可是我现在只是开启了个服务,什么操作都没做,客户端也没开。为什么还是占那么多CPU
      

  3.   

    在Remoting中当注册通道的时候,就自动开启了通道的监听
      

  4.   

    哦,我的代码粘错了
    是这样的
     TcpServerChannel channel = new TcpServerChannel(9000);
                ChannelServices.RegisterChannel(channel,false);
               
                 RemotingConfiguration.RegisterWellKnownServiceType(typeof(SmartKernel.Net.Monitor), "MonitorServerUrl", WellKnownObjectMode.Singleton);
      

  5.   

    你试一下关闭监听,看CPU资源是否下降。
    如果是这样,说明是监听在消耗资源
    只要你注册,那么监听就默认开了。你是玩啥必须要用这个,为什么不走socket?
      

  6.   

    换其他端口监听试试
    TcpServerChannel channel = new TcpServerChannel(1234); 
    ChannelServices.RegisterChannel(channel); HttpServiceChannel channel = new HttpServerChannel(1234); 
    ChannelServices.RegisterChannel(channel); 
      

  7.   

    但我用另外一台机子就不会占用好多资源,真是见鬼了。
    我写一个远程桌面程序,scoket还不熟悉,呵呵,要学习下。
      

  8.   

    远程操作 Remoting 规则:
    1. 宁可使用管理配置(配置文件)而不使用程序自动配置。 
    2. 总是在单独调用对象里完成IDisposable。 
    3. 远程操作时总是选用TCP信道和二进制格式 
    a) 除非设置了防火墙 
    4. 总是为一扎对象提供一个null租约。 
    Public class MySingleton : MarshalByRefObject 

    public override object InitializeLifetimeService() 

    return null; 


    5. 总是为客户端激活的对象提供sponsor。这个sponsor应该返回初始租约时刻。 
    6. 在客户端应用程序停止时总是不要注册sponsor。 
    7. 总是将远程对象放在类库里。 
    8. 避免使用SoapSuds。 
    9. 避免宿主IIS. 
    10. 避免使用单一定向的信道。 
    11. 总是在Main()方法里载入远程配置文件,即使该文件为空。并且该应用程序没有使用远程操作。 
    a) 允许在该文件重新定义远程调用,配置信道和改变应用程序发布(添加信道等)等。 
    Static void Main() 

    RemotingConfiguration.Configue(“MyApp.exe.config”); 
    /*Rest of Main()*/ 

    12. 避免对远程对象激活时使用Activator.GetObject() and Activator.CreateInstance()。而是使用new。 
    13. 总是在客户端注册port(),目的是允许递归调用。 
    14. 总是将客户端和服务器端的类型过滤设置为Full,使其可以递归调用。 
    Host Config file: 
    <channels> 
    <channel ref = “tcp” port = “8005”> 
    <serverProviders> 
    <formatter ref = “soap” typeFilterLevel = “Full”/> 
    <formatter ref = “binary” typeFilterLevel = “Full”/> 原文地址:http://www.xue5.com/itedu/200802/111451.html