现在因为需要,要从asp.net页面中发起一个remoting调用,但是经查知,asp.net代码属于部分受信任代码,无法访问remoting中内容,如何解决?

解决方案 »

  1.   

    http://www.eggheadcafe.com/articles/20031124.asp
      

  2.   

    我不是要这样的方式,我使用一个独立的进程或者服务来承载Remoting服务,不是把Remoting放在IIS中,这样该怎么做?
      

  3.   

    做一个 exe 就可以了。
      

  4.   

    服务器端代码   
      表1:Server.cs源代码 
        
     Server.cs
    using System;
    using System.Runtime.Remoting;public class Server{
    public static void Main(string[] Args){// Load the configuration file
    RemotingConfiguration.Configure("server.exe.config");Console.WriteLine("The server is listening. Press Enter to exit....");
    Console.ReadLine(); Console.WriteLine("GC'ing.");
    GC.Collect();
    GC.WaitForPendingFinalizers();}

        表2:Server.exe.config源代码
    <SYSTEM.RUNTIME.REMOTING>
    <APPLICATION>
    <SERVICE>
    <ACTIVATED type="ClientActivatedType, RemoteType">
    </SERVICE>
    <CHANNELS>
    <CHANNEL ref="http" port="8088">
    </CHANNELS>
    </APPLICATION>
    </SYSTEM.RUNTIME.REMOTING>
    </CONFIGURATION> 
        表3:RemoteType.cs源代码 
    using System;
    using System.Runtime.Remoting.Lifetime;
    using System.Security.Principal;public class ClientActivatedType : MarshalByRefObject{private int i;
     // override the lease settings for this object
     public override Object InitializeLifetimeService(){
    return null;
     } public string RemoteMethod(){// announce to the server that we've been called.
    Console.WriteLine("ClientActivatedType.RemoteMethod called.");// report our client identity namei=this.GetHashCode(); 
    return "RemoteMethod called. " + i;
     } public string RemoteMethod1(){
    return "RemoteMethod1 called. " + i;}
    }
      

  5.   

    那我要从Asp.net中调用外部进程中的对象呢?该怎么做?有人能给一个完整的范例么?