[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.remoting

.Net Remoting, Config. Files and Interfaces

José Manuel Chávez

9/30/2004 11:23:00 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/USEINTERFACESWITHCONFIG...

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
Accenture Technology Solutions
1 Answer

Ken Kolda

10/1/2004 2:56:00 PM

0

See comments inline below...

"José Manuel Chávez" <desarrollodotnet[at]yahoo[dot]com> wrote in message
news:3DA90E2C-F86F-4F71-8733-544DD4F98765@microsoft.com...
> 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" />
>

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.


> 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
> ?

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.

>
>
> 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"));
> }
>

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