due to security restriction, can not access type system.runtime.remoting.objref

Locked due to security restriction, can not access type system.runtime.remoting.objref

  • Tuesday, September 04, 2012 3:20 AM
     
      Has Code

    due to security restriction, can not access type system.runtime.remoting.objref

    After running example Chapter04\Sponsor of book distributed .net programming in c#

    got error

    due to security restriction, can not access type system.runtime.remoting.objref
    at leaseInfo.Register(new CustomerClientSponsor());
    static void Main(string[] args)
          {
             // Load the configuration file
             RemotingConfiguration.Configure("MathClient.exe.config");
             Customer cust = new Customer("Homer Simpson");
             
             // Register the client side sponsor
             ILease leaseInfo = (ILease)cust.GetLifetimeService();
             leaseInfo.Register(new CustomerClientSponsor());
             // Loop until user enters "q" to quit
             Console.WriteLine("Enter 'q' to quit: ");       
             do
             {
                Console.WriteLine("Server returns: {0}", cust.SayHello());
             }while (Console.ReadLine() != "q");
          }
     class CustomerClientSponsor : MarshalByRefObject, ISponsor
       {
          private int mRenewCount = 0;
          
          // Implements ISponsor.Renewal
          public TimeSpan Renewal(ILease leaseInfo)
          {
             if (mRenewCount < 3)
             {
                mRenewCount++;
                // Just a trace messsage for testing.
                Console.WriteLine("CustomerClientSponsor.Renewal()");
                return TimeSpan.FromSeconds(5);
             } 
             else 
             {
                // Just a trace messsage for testing.
                Console.WriteLine("CustomerClientSponsor.Renewal(), returning 0 time!");
                return TimeSpan.FromSeconds(0);
             }
          }
       }