C#通讯编程--remoting

+展开
-C#
using System; 
 
namespace Remotable 

     
    public class RemotableType : MarshalByRefObject 
    { 
        private string _internalString = "This is the RemotableType."
        public string StringMethod() 
        { 
            return _internalString; 
        } 
    } 
 




using System; 
using System.Runtime.Remoting; 
 
 
namespace RemotingFirst 

 
    public class Listener 
    { 
        public static void Main() 
        { 
            RemotingConfiguration.Configure("Listener.exe.config"); 
            Console.WriteLine("Listening for requests. Press Enter to exit"); 
            Console.ReadLine(); 
        } 
    } 
 



using System; 
using System.Runtime.Remoting; 
 
 
namespace Client 

 
 
    public class Client 
    { 
 
        public static void Main() 
        { 
            RemotingConfiguration.Configure("Client.exe.config"); 
            Remotable.RemotableType remoteObject = new Remotable.RemotableType(); 
            Console.WriteLine(remoteObject.StringMethod()); 
        } 
    } 
 


Listener.exe.config

+展开
-XML
<?xml version="1.0" encoding="utf-8" ?> 
<configuration> 
    <system.runtime.remoting> 
      <application> 
         <service> 
            <wellknown  
               mode="Singleton"  
               type="Remotable.RemotableType, RemotableType"  
               objectUri="RemotableType.rem
            />
 
         </service> 
         <channels> 
            <channel ref="httpport="8989"/> 
         </channels> 
      </application> 
    </system.runtime.remoting> 
</configuration>

加支付宝好友偷能量挖...


评论(0)网络
阅读(107)喜欢(0)Asp.Net/C#/WCF