Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old April 14th, 2005, 06:51 AM
Registered User
 
Join Date: Apr 2005
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Error in remoting using .config

In your book
C# Web Services (Building Web Services with .NET Remoting and ASP.NET)

(First Indian Reprint: January 2002 ISBN: 81-7366-304-1.)
(Originally Printed in United States. ISBN: 1-861004-39-7)


There is an example where the server and client are created using configuration file. Page-134 to Page 138. (In chapter 6).

Sir after running the server which is waiting to respond to client, when I run the client. It uses the local assembly (MyRemoteObject.dll) to create the object. Which was used to compile the code. Instead of taking from server or referring the config file. Please help me.

I also want the link to download the code for this book. I am unable to locate it on the site.


Thanking you.
Amit Mirchandani.

Code---


////MyRemoteObject.cs/////////////
using System;

namespace amit
{
   public class MyRemoteObject : System.MarshalByRefObject
   {
      public MyRemoteObject()
      {
         System.Console.WriteLine("Constructor Called");
      }

      public string Hello(string name)
      {
         Console.WriteLine("Hello " + name);
         return "Hello Mr " + name;
      }

   }
///////////////////////////////////////////////////////


///////////SimpleServer.config////////////////////////
<configuration>
   <system.runtime.remoting>
      <application name="SimpleServer">
          <service>
                  <wellknown mode="SingleCall" type="amit.MyRemoteObject, MyRemoteObject" objectUri="MyRemoteObject" />
          </service>
          <channels>
            <channel ref="tcp server" port="9000" />
        </channels>
      </application>
   </system.runtime.remoting>
</configuration>
///////////////////////////////////////////////////////////////

//////SimpleServer.cs/////////////////////////
using System;
using System.Runtime.Remoting;

namespace amit
{
   class SimpleServer
   {
      static void Main(string[] ar)
      {
        RemotingConfiguration.Configure("SimpleServer.conf ig");
        Console.WriteLine("Press ne key");
        Console.ReadLine();


      }

   }
//////////////////////////////////////////////////////////


////////SimpleClient.config//////////
<configuration>
    <system.runtime.remoting>
        <application name="SimpleClient">
            <client url="tcp://localhost:9000/SimpleServer">
                                <wellknown type="amit.MyRemoteobject, MyRemoteObject" url="tcp://localhost:9000/SimpleServer/MyRemoteObject" />
             </client>
             <channels>
                <channel ref="tcp client" />
             </channels>
        </application>
    </system.runtime.remoting>
</configuration>
//////////////////////////////////////////////////////////////


///////SimpleClient.cs//////////////////////////
using System;
using System.Runtime.Remoting;

namespace amit
{
   class SimpleClient
   {
      static void Main(string[] ar)
      {
         RemotingConfiguration.Configure("SimpleClient.conf ig");
         MyRemoteObject obj = new MyRemoteObject();
         Console.WriteLine(obj.Hello("amit"));

      }

   }
}
///////////////////////////////////////////////////////////
 
Old April 23rd, 2005, 01:19 PM
Authorized User
 
Join Date: May 2004
Posts: 83
Thanks: 0
Thanked 1 Time in 1 Post
Default

Dear amitmirchandani,

There are two issues with the configuration files you've provided. The first on is this line in your client configuration file:
Code:
<client url="tcp://localhost:9000/SimpleServer">
The attribute url is used in the client tag if you're working with CAO (Client Activated Objects). For SAO (Server ACtivated Objects), like the one you've used, the client tag contains no attributes. So remove this extra attribute. All else is fine with your server and client config files.

The second issue is the names of your config files. The general structure for naming a config file in .NET is assemblyname.extension.config, i.e. if your assembly's name is MyAssembly.exe, then the config file for your assemble should be named MyAssembly.exe.config. You can see that you've not followed this convention. Try renaming your config files so that they adhere to this standard. After you do this, don't forget to modify the call to the RemotingConfiguration.Configure() method accordingly.

I hope this should solve your problem.

Regards,

ejan





Similar Threads
Thread Thread Starter Forum Replies Last Post
web.config error koco ASP.NET 2.0 Basics 1 February 16th, 2007 12:04 PM
Config error--machine.config sunithavasudevan ASP.NET 1.0 and 1.1 Professional 2 October 10th, 2006 07:14 AM
Remoting Callback Error maheshgv All Other Wrox Books 1 December 5th, 2005 03:33 PM
.NET Framework 1.1 upgrade: Remoting error agarwalmk General .NET 0 March 11th, 2004 02:42 PM
Error in remoting SenthilVelM .NET Web Services 0 November 12th, 2003 08:44 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.