Groups | Blog | Home
all groups > dotnet remoting > september 2004 >

dotnet remoting : .Net Remoting, Config. Files and Interfaces


José Manuel Chávez
9/30/2004 4:23:02 PM
I have a Windows Service with the following configuration in the app.config:

<configuration>
<system.runtime.remoting>
<application name="RemoteHostService">
<service>
<wellknown type="Telefonica.Morosos.BusinessLogic.Facade.Agencia,
Telefonica.Morosos.BusinessLogic.IFacade"
objectUri="Morosos.Agencia"
mode="Singleton" />
</service>
<channels>
<channel ref="tcp" port="8085">
<serverProviders>
<formatter ref="binary" />
</serverProviders>
</channel>
</channels>
</application>
</system.runtime.remoting>
</configuration>

The first question is : My Remotable class is:
Telefonica.Morosos.BusinessLogic.Facade.Agencia

I distribute only the Interface called: IAgencia which is in the assembly:
Telefonica.Morosos.BusinessLogic.IFacade

Is the following ok?
<wellknown type="Telefonica.Morosos.BusinessLogic.Facade.Agencia,
Telefonica.Morosos.BusinessLogic.IFacade"
objectUri="Morosos.Agencia"
mode="Singleton" />

Second Question: Do I need to add a reference in my windows service project
to both Projects:
Telefonica.Morosos.BusinessLogic.Facade and
Telefonica.Morosos.BusinessLogic.IFacade
?


Third question:
In My Web Aapplication (Client) I have the following in the Globla.asax:

protected void Application_Start(Object sender, EventArgs e)
{
RemotingConfiguration.Configure(Server.MapPath("Remoting.config"));
}

In Remoting.Config I have:

<configuration>
<system.runtime.remoting>
<application>
<channels>
<channel ref="tcp" />
</channels>
<client>
<wellknown type="IAgencia, Telefonica.Morosos.BusinessLogic.IFacade"
url="tcp://localhost:0/Morosos.Agencia" />
</client>
</application>
</system.runtime.remoting>
</configuration>

And I use a class from here:

http://www.thinktecture.com/Resources/RemotingFAQ/USEINTERFACESWITHCONFIGFILES.html

So I get the following code in my Page_Load event:

IAgencia obj = (IAgencia) RemotingHelper.GetObject(typeof(IAgencia));


After all. I receive the following error:

Type not found!
Description: An unhandled exception occurred during the execution of the
current web request. Please review the stack trace for more information about
the error and where it originated in the code.

Exception Details: System.Runtime.Remoting.RemotingException: Type not found!

Source Error:


Line 17: if (entr == null)
Line 18: {
Line 19: throw new RemotingException("Type not found!");
Line 20: }


So anyone can tell me? What's going on?


--
--
Este mensaje no implica responsabilidad alguna.
--
José Manuel
Programador
Ken Kolda
10/1/2004 7:56:05 AM
See comments inline below...

[quoted text, click to view]

No -- you must supply the name for a concrete type for the wellknown type on
the server. Consider this: when a request comes in for your object and all
you've supplied to the remoting infrastructre is an interface type, what
class should it instantiate to service those requests? The remoting system
is going to call "new IFacade()" which, of course, makes no sense. That
said, just because you expose the concrete type doesn't mean the client
needs this object's complete definition -- it can access it using the
interface only.


[quoted text, click to view]

I believe you will, but even if you don't have to explicitly add the
reference, both assemblies are dependencies and .NET will automatically
detect this and copy both to the bin folder for the service's project.

[quoted text, click to view]

I believe that when using a web app you must place your ermoting
configuration information inside your web.config file. It will then be
automatically read without the need to call
RemotingConfiguration.Configure(). Give that a shot and see if it works for
you.

Ken

TheCodeFox
3/26/2005 1:57:50 PM

[quoted text, click to view]


Nupski: you'll want to avoid structuring things this way to ensure the
solution is as loosely coupled as possible.
The interface libraries and the implementation libraries should be seperated
where possible.
Doing so, you only need the interface library on the client side and the
client need not know the specifics of the object instantiated server side;
..NET would only copy the "dependency" if your client solution has a ref to
the implementation library;

Short answer: abstract the interface definition from the implementation and
reference only the interface lib from the client.

AddThis Social Bookmark Button