Re: Hosting On IIS

From: Ken Kolda (ken.kolda_at_elliemae-nospamplease.com)
Date: 09/10/04


Date: Fri, 10 Sep 2004 11:07:45 -0700

You have several issues you need to resolve, some of which may be just that
you didn't correctly copy the code into your post. Your issues are:

1) You're mixing two means of activating your object in your client code.
You should either register the well known object (either via the config file
or thru code) OR you should use the Activator.GetObject() -- there's no need
to do both. So, to use the activator (which is my preference), change the
code to:

IPlayer player = (IPlayer)Activator.GetObject(typeof(IPlayer),
"http://localhost:80/Test/MyServer.rem");

Note that you have to provide the full URL in the call to GetObject() -- you
had omitted the "MyServer.rem".

2) Your MyRemote() object only has a parameterized constructor. In order to
be used as a server-activated object, it must have a zero-argument
constructor.

3) The DLLs should be in a subdirectory of your web app named "bin".

4) You've specified a binary formatter on the client side but not on the
server side.

Ken

"Naeem Hassan Dad" <Naeem Hassan Dad@discussions.microsoft.com> wrote in
message news:E35AD241-B6CE-4FF9-A7F3-D897D31E72EA@microsoft.com...
> Hello
> I am really fed up by the following simple problem. I write a
> interface IPlyer and produce RemotingLibrary.dll. I Implement this
Interface
> using MyRemote class which is also a Remote Object and it produce
> RemoteServer.dll.
> I create a virtual directory named Test and copy these dlls in this
> directory to host remote object on IIS. And An
> Problem is occur when I execute client application. That is when I used
> configuration file for configuration. The Exception occur file not found
but
> file is there after exception occur file deleted from its location.
> Second When i used to configure using
> RemotingConfiguration.RegisterWellKnownClientType(typeof(IPlayer),
"http://localhost:80/Test/MyServer.rem");
> It executed this statment but excption of logon failde occur when reomote
is
> called.
>
> Here is the source of this problem including configuration files. All
these
> files in same virtual directory and this virtual directory has no
Annonymous
> Access .Can some one copy these and compile to reproduce the behavior or
tell
> me where I went wrong.
>
> //RemotingLibrary.cs
> namespace RemotingLibrary
> {
> public interface IPlayer
> {
> string GetCurrentSong();
> }
> }
> --------------------------------------------------------------------------
----------------
> here is Implementation of IPlyer which is also a remote object
> //RemotingServer.css
>
> namespace RemotingServer
> {
> public class MyRemote: MarshalByRefObject, IPlayer
> {
> string song;
>
> public MyRemote(string song)
> {
> this.song = song;
> }
>
> public string GetCurrentSong()
> {
> return song;
> }
> }
> }
> --------------------------------------------------------------------------
-------------------
> And Here is the client Application
> //RemotingClient.cs
> using System;
> using System.Runtime.Remoting;
> using RemotingLibrary;
>
> namespace RemotingClient
> {
> class RemoteClient
> {
> public static void Main()
>
> { /*RemotingConfiguration.RegisterWellKnownClientType(typeof(IPlayer),
"http://localhost:80/Test/MyServer.rem");*/
>
> RemotingConfiguration.Configure("RemotingClient.exe.config");
> IPlayer player = (IPlayer)Activator.GetObject(typeof(IPlayer),
> "http://localhost:80/Test");
>
> try
> {
> string str;
> Console.WriteLine(player.GetCurrentSong());
> }
> catch(Exception ex)
> {
> error = ex.Message;
> }
> }
> }
> }
> --------------------------------------------------------------------------
--------
> //Web.config
> <configuration>
> <system.runtime.remoting>
> <application>
> <service>
> <wellknown mode="SingleCall" type="RemotingServer.MyRemote,
> RemotingServer" objectUri="MyServer.rem" />
>
> </service>
>
> <channels>
> <channel ref="http">
> </channel>
> </channels>
> </application>
> </system.runtime.remoting>
> </configuration>
>
> --------------------------------------------------------------------------
-------------------
> //RemotingClient.exe.config
> <configuration>
> <system.runtime.remoting>
> <application>
> <channels>
> <channel ref="http" useDefaultCredentials="true" port="0">
> <clientProviders>
> <formatter
> ref="binary"
> />
> </clientProviders>
> </channel>
> </channels>
> <client>
> <wellknown
> url="http://localhost:80/Test/Server.rem"
> type="RemotingServer.MyRemote, RemotingServer"
> />
> </client>
> </application>
> </system.runtime.remoting>
> </configuration>
>
>



Relevant Pages

  • Hosting On IIS
    ... I create a virtual directory named Test and copy these dlls in this ... directory to host remote object on IIS. ... configuration file for configuration. ... namespace RemotingServer ...
    (microsoft.public.dotnet.framework.remoting)
  • Re: Hosting On IIS
    ... I also face the same problem, while hosting on IIS. ... Create a virtual directory on IIS. ... > string GetCurrentSong(); ... > namespace RemotingServer ...
    (microsoft.public.dotnet.framework.remoting)
  • Re: Accessing server resources from remotable object
    ... It should return the physical path associated with any virtual directory you ... > the proxy of the remote object executes, happens to have the same file ... >> Use a naming convention specific to each client if you are going to ...
    (microsoft.public.dotnet.framework.remoting)
  • Re: Accessing server resources from remotable object
    ... Your remoting host is on the IIS server, so you can have the remote object ... write to a physical path. ... Your clients can then access the persisted file via ... the virtual directory and http. ...
    (microsoft.public.dotnet.framework.remoting)
  • Re: Accessing server resources from remotable object
    ... > Your remoting host is on the IIS server, so you can have the remote object ... > write to a physical path. ... > the virtual directory and http. ... > Use a naming convention specific to each client if you are going to expect ...
    (microsoft.public.dotnet.framework.remoting)