[lnkForumImage]
TotalShareware - Download Free Software

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


 

Forums >

microsoft.public.dotnet.framework.remoting

Remoting exception when using interfaces

Henke

9/13/2004 2:17:00 PM

Hi!
I have a 3-tier solution that uses remoting from the business logic layer to
the data access layer. Every business manager object implements an interface
that is used by the ASP.NET clients to communicate with the business logic.
Ie I have a CustomerManager object and a ICustomerManager interface. Only my
interface assembly is distributed with the client.

I "create" my managers in the client by calling:
ICustomerManager cm
=(ICustomerManager)Activator.GetObject(typeof(ICustomerManager), url);

When I try to call a method on the cm instance I get an exception:
"Attempted to create a well-known object of type
ICustomerManager. Well known objects must derive from the
MarshalByRefObject."

The implementation of the CustomerManager looks like this:
public class CustomerManager : MarshalByRefObject, ICustomerManager
{
...
}

What am I doing wrong, I don't want do distribute my manager assemblies, but
just the interface assemblies?

Thanks in advance!
/Henke


10 Answers

Ken Kolda

9/13/2004 3:20:00 PM

0

Can you show the server-side code you use to register the well-known object?

Ken


"Henke" <henke_nord@hotmail.com> wrote in message
news:%23FyuiyZmEHA.2020@TK2MSFTNGP09.phx.gbl...
> Hi!
> I have a 3-tier solution that uses remoting from the business logic layer
to
> the data access layer. Every business manager object implements an
interface
> that is used by the ASP.NET clients to communicate with the business
logic.
> Ie I have a CustomerManager object and a ICustomerManager interface. Only
my
> interface assembly is distributed with the client.
>
> I "create" my managers in the client by calling:
> ICustomerManager cm
> =(ICustomerManager)Activator.GetObject(typeof(ICustomerManager), url);
>
> When I try to call a method on the cm instance I get an exception:
> "Attempted to create a well-known object of type
> ICustomerManager. Well known objects must derive from the
> MarshalByRefObject."
>
> The implementation of the CustomerManager looks like this:
> public class CustomerManager : MarshalByRefObject, ICustomerManager
> {
> ...
> }
>
> What am I doing wrong, I don't want do distribute my manager assemblies,
but
> just the interface assemblies?
>
> Thanks in advance!
> /Henke
>
>


Henke

9/13/2004 3:33:00 PM

0

Yes, here it is:
TcpChannel channel = new TcpChannel(2099);
ChannelServices.RegisterChannel(channel);

RemotingConfiguration.RegisterWellKnownServiceType(typeof(ICustomerManager),
"RemoteServer",
WellKnownObjectMode.SingleCall);

/Henke

"Ken Kolda" <ken.kolda@elliemae-nospamplease.com> skrev i meddelandet
news:%23RJGCVamEHA.3484@TK2MSFTNGP10.phx.gbl...
> Can you show the server-side code you use to register the well-known
object?
>
> Ken
>
>
> "Henke" <henke_nord@hotmail.com> wrote in message
> news:%23FyuiyZmEHA.2020@TK2MSFTNGP09.phx.gbl...
> > Hi!
> > I have a 3-tier solution that uses remoting from the business logic
layer
> to
> > the data access layer. Every business manager object implements an
> interface
> > that is used by the ASP.NET clients to communicate with the business
> logic.
> > Ie I have a CustomerManager object and a ICustomerManager interface.
Only
> my
> > interface assembly is distributed with the client.
> >
> > I "create" my managers in the client by calling:
> > ICustomerManager cm
> > =(ICustomerManager)Activator.GetObject(typeof(ICustomerManager), url);
> >
> > When I try to call a method on the cm instance I get an exception:
> > "Attempted to create a well-known object of type
> > ICustomerManager. Well known objects must derive from the
> > MarshalByRefObject."
> >
> > The implementation of the CustomerManager looks like this:
> > public class CustomerManager : MarshalByRefObject, ICustomerManager
> > {
> > ...
> > }
> >
> > What am I doing wrong, I don't want do distribute my manager assemblies,
> but
> > just the interface assemblies?
> >
> > Thanks in advance!
> > /Henke
> >
> >
>
>


Ken Kolda

9/13/2004 3:53:00 PM

0

Ahh.. there's your problem. When you cann RegisterWellKnownServiceType, you
have to pass it a class Type, not an interface (after all, the remoting
framework has to know what type to instantiate to fulfill the remoting
requests it receives). Just change your call to use CustomerMnager instead
of ICustomerManager. From the client side, it will still just use
ICustomerManager and does not need the CustomerManager implementation, so
you've still achieved the separation you want.

Ken


"Henke" <henke_nord@hotmail.com> wrote in message
news:eF3NBdamEHA.644@tk2msftngp13.phx.gbl...
> Yes, here it is:
> TcpChannel channel = new TcpChannel(2099);
> ChannelServices.RegisterChannel(channel);
>
>
RemotingConfiguration.RegisterWellKnownServiceType(typeof(ICustomerManager),
> "RemoteServer",
> WellKnownObjectMode.SingleCall);
>
> /Henke
>
> "Ken Kolda" <ken.kolda@elliemae-nospamplease.com> skrev i meddelandet
> news:%23RJGCVamEHA.3484@TK2MSFTNGP10.phx.gbl...
> > Can you show the server-side code you use to register the well-known
> object?
> >
> > Ken
> >
> >
> > "Henke" <henke_nord@hotmail.com> wrote in message
> > news:%23FyuiyZmEHA.2020@TK2MSFTNGP09.phx.gbl...
> > > Hi!
> > > I have a 3-tier solution that uses remoting from the business logic
> layer
> > to
> > > the data access layer. Every business manager object implements an
> > interface
> > > that is used by the ASP.NET clients to communicate with the business
> > logic.
> > > Ie I have a CustomerManager object and a ICustomerManager interface.
> Only
> > my
> > > interface assembly is distributed with the client.
> > >
> > > I "create" my managers in the client by calling:
> > > ICustomerManager cm
> > > =(ICustomerManager)Activator.GetObject(typeof(ICustomerManager), url);
> > >
> > > When I try to call a method on the cm instance I get an exception:
> > > "Attempted to create a well-known object of type
> > > ICustomerManager. Well known objects must derive from the
> > > MarshalByRefObject."
> > >
> > > The implementation of the CustomerManager looks like this:
> > > public class CustomerManager : MarshalByRefObject, ICustomerManager
> > > {
> > > ...
> > > }
> > >
> > > What am I doing wrong, I don't want do distribute my manager
assemblies,
> > but
> > > just the interface assemblies?
> > >
> > > Thanks in advance!
> > > /Henke
> > >
> > >
> >
> >
>
>


Robert Jordan

9/13/2004 6:17:00 PM

0

Ken Kolda wrote:

> Ahh.. there's your problem. When you cann RegisterWellKnownServiceType, you
> have to pass it a class Type, not an interface (after all, the remoting
> framework has to know what type to instantiate to fulfill the remoting
> requests it receives). Just change your call to use CustomerMnager instead
> of ICustomerManager. From the client side, it will still just use
> ICustomerManager and does not need the CustomerManager implementation, so
> you've still achieved the separation you want.

BTW, a stub implementation of CustomerManager can be generated
with SoapSuds.exe. You should always deploy the stub with the
clients instead of the real implementation.

bye
Rob


>
> Ken
>
>
> "Henke" <henke_nord@hotmail.com> wrote in message
> news:eF3NBdamEHA.644@tk2msftngp13.phx.gbl...
>
>>Yes, here it is:
>>TcpChannel channel = new TcpChannel(2099);
>>ChannelServices.RegisterChannel(channel);
>>
>>
>
> RemotingConfiguration.RegisterWellKnownServiceType(typeof(ICustomerManager),
>
>> "RemoteServer",
>> WellKnownObjectMode.SingleCall);
>>
>>/Henke
>>
>>"Ken Kolda" <ken.kolda@elliemae-nospamplease.com> skrev i meddelandet
>>news:%23RJGCVamEHA.3484@TK2MSFTNGP10.phx.gbl...
>>
>>>Can you show the server-side code you use to register the well-known
>>
>>object?
>>
>>>Ken
>>>
>>>
>>>"Henke" <henke_nord@hotmail.com> wrote in message
>>>news:%23FyuiyZmEHA.2020@TK2MSFTNGP09.phx.gbl...
>>>
>>>>Hi!
>>>>I have a 3-tier solution that uses remoting from the business logic
>>
>>layer
>>
>>>to
>>>
>>>>the data access layer. Every business manager object implements an
>>>
>>>interface
>>>
>>>>that is used by the ASP.NET clients to communicate with the business
>>>
>>>logic.
>>>
>>>>Ie I have a CustomerManager object and a ICustomerManager interface.
>>
>>Only
>>
>>>my
>>>
>>>>interface assembly is distributed with the client.
>>>>
>>>>I "create" my managers in the client by calling:
>>>>ICustomerManager cm
>>>>=(ICustomerManager)Activator.GetObject(typeof(ICustomerManager), url);
>>>>
>>>>When I try to call a method on the cm instance I get an exception:
>>>>"Attempted to create a well-known object of type
>>>>ICustomerManager. Well known objects must derive from the
>>>>MarshalByRefObject."
>>>>
>>>>The implementation of the CustomerManager looks like this:
>>>>public class CustomerManager : MarshalByRefObject, ICustomerManager
>>>>{
>>>> ...
>>>>}
>>>>
>>>>What am I doing wrong, I don't want do distribute my manager
>
> assemblies,
>
>>>but
>>>
>>>>just the interface assemblies?
>>>>
>>>>Thanks in advance!
>>>>/Henke
>>>>
>>>>
>>>
>>>
>>
>
>

Ken Kolda

9/13/2004 6:26:00 PM

0

By using interface-based remoting no stub is necessary -- he just deploys
the assembly containing the interface definition. Creating a stub via
SoapSuds is alternative to using interfaces (although I've never seen the
advantage to it).

Ken


"Robert Jordan" <robertj@gmx.net> wrote in message
news:ci4o7r$t8u$03$1@news.t-online.com...
> Ken Kolda wrote:
>
> > Ahh.. there's your problem. When you cann RegisterWellKnownServiceType,
you
> > have to pass it a class Type, not an interface (after all, the remoting
> > framework has to know what type to instantiate to fulfill the remoting
> > requests it receives). Just change your call to use CustomerMnager
instead
> > of ICustomerManager. From the client side, it will still just use
> > ICustomerManager and does not need the CustomerManager implementation,
so
> > you've still achieved the separation you want.
>
> BTW, a stub implementation of CustomerManager can be generated
> with SoapSuds.exe. You should always deploy the stub with the
> clients instead of the real implementation.
>
> bye
> Rob
>
>
> >
> > Ken
> >
> >
> > "Henke" <henke_nord@hotmail.com> wrote in message
> > news:eF3NBdamEHA.644@tk2msftngp13.phx.gbl...
> >
> >>Yes, here it is:
> >>TcpChannel channel = new TcpChannel(2099);
> >>ChannelServices.RegisterChannel(channel);
> >>
> >>
> >
> >
RemotingConfiguration.RegisterWellKnownServiceType(typeof(ICustomerManager),
> >
> >> "RemoteServer",
> >> WellKnownObjectMode.SingleCall);
> >>
> >>/Henke
> >>
> >>"Ken Kolda" <ken.kolda@elliemae-nospamplease.com> skrev i meddelandet
> >>news:%23RJGCVamEHA.3484@TK2MSFTNGP10.phx.gbl...
> >>
> >>>Can you show the server-side code you use to register the well-known
> >>
> >>object?
> >>
> >>>Ken
> >>>
> >>>
> >>>"Henke" <henke_nord@hotmail.com> wrote in message
> >>>news:%23FyuiyZmEHA.2020@TK2MSFTNGP09.phx.gbl...
> >>>
> >>>>Hi!
> >>>>I have a 3-tier solution that uses remoting from the business logic
> >>
> >>layer
> >>
> >>>to
> >>>
> >>>>the data access layer. Every business manager object implements an
> >>>
> >>>interface
> >>>
> >>>>that is used by the ASP.NET clients to communicate with the business
> >>>
> >>>logic.
> >>>
> >>>>Ie I have a CustomerManager object and a ICustomerManager interface.
> >>
> >>Only
> >>
> >>>my
> >>>
> >>>>interface assembly is distributed with the client.
> >>>>
> >>>>I "create" my managers in the client by calling:
> >>>>ICustomerManager cm
> >>>>=(ICustomerManager)Activator.GetObject(typeof(ICustomerManager), url);
> >>>>
> >>>>When I try to call a method on the cm instance I get an exception:
> >>>>"Attempted to create a well-known object of type
> >>>>ICustomerManager. Well known objects must derive from the
> >>>>MarshalByRefObject."
> >>>>
> >>>>The implementation of the CustomerManager looks like this:
> >>>>public class CustomerManager : MarshalByRefObject, ICustomerManager
> >>>>{
> >>>> ...
> >>>>}
> >>>>
> >>>>What am I doing wrong, I don't want do distribute my manager
> >
> > assemblies,
> >
> >>>but
> >>>
> >>>>just the interface assemblies?
> >>>>
> >>>>Thanks in advance!
> >>>>/Henke
> >>>>
> >>>>
> >>>
> >>>
> >>
> >
> >


Robert Jordan

9/13/2004 7:40:00 PM

0

Hi Ken,

> By using interface-based remoting no stub is necessary -- he just deploys
> the assembly containing the interface definition. Creating a stub via
> SoapSuds is alternative to using interfaces (although I've never seen the
> advantage to it).

Well, as you stated before: a class type is required to be able
to instantiate the CAO, and that type must implemenent the
certain interface. You have 2 choices: deploy the whole
implementation (bad) or deploy the stubs.

[Anyway, I'd go for the 3rd way: singleton with factory
pattern]

bye
Rob


>
> Ken
>
>
> "Robert Jordan" <robertj@gmx.net> wrote in message
> news:ci4o7r$t8u$03$1@news.t-online.com...
>
>>Ken Kolda wrote:
>>
>>
>>>Ahh.. there's your problem. When you cann RegisterWellKnownServiceType,
>
> you
>
>>>have to pass it a class Type, not an interface (after all, the remoting
>>>framework has to know what type to instantiate to fulfill the remoting
>>>requests it receives). Just change your call to use CustomerMnager
>
> instead
>
>>>of ICustomerManager. From the client side, it will still just use
>>>ICustomerManager and does not need the CustomerManager implementation,
>
> so
>
>>>you've still achieved the separation you want.
>>
>>BTW, a stub implementation of CustomerManager can be generated
>>with SoapSuds.exe. You should always deploy the stub with the
>>clients instead of the real implementation.
>>
>>bye
>>Rob
>>
>>
>>
>>>Ken
>>>
>>>
>>>"Henke" <henke_nord@hotmail.com> wrote in message
>>>news:eF3NBdamEHA.644@tk2msftngp13.phx.gbl...
>>>
>>>
>>>>Yes, here it is:
>>>>TcpChannel channel = new TcpChannel(2099);
>>>>ChannelServices.RegisterChannel(channel);
>>>>
>>>>
>>>
>>>
> RemotingConfiguration.RegisterWellKnownServiceType(typeof(ICustomerManager),
>
>>>> "RemoteServer",
>>>> WellKnownObjectMode.SingleCall);
>>>>
>>>>/Henke
>>>>
>>>>"Ken Kolda" <ken.kolda@elliemae-nospamplease.com> skrev i meddelandet
>>>>news:%23RJGCVamEHA.3484@TK2MSFTNGP10.phx.gbl...
>>>>
>>>>
>>>>>Can you show the server-side code you use to register the well-known
>>>>
>>>>object?
>>>>
>>>>
>>>>>Ken
>>>>>
>>>>>
>>>>>"Henke" <henke_nord@hotmail.com> wrote in message
>>>>>news:%23FyuiyZmEHA.2020@TK2MSFTNGP09.phx.gbl...
>>>>>
>>>>>
>>>>>>Hi!
>>>>>>I have a 3-tier solution that uses remoting from the business logic
>>>>
>>>>layer
>>>>
>>>>
>>>>>to
>>>>>
>>>>>
>>>>>>the data access layer. Every business manager object implements an
>>>>>
>>>>>interface
>>>>>
>>>>>
>>>>>>that is used by the ASP.NET clients to communicate with the business
>>>>>
>>>>>logic.
>>>>>
>>>>>
>>>>>>Ie I have a CustomerManager object and a ICustomerManager interface.
>>>>
>>>>Only
>>>>
>>>>
>>>>>my
>>>>>
>>>>>
>>>>>>interface assembly is distributed with the client.
>>>>>>
>>>>>>I "create" my managers in the client by calling:
>>>>>>ICustomerManager cm
>>>>>>=(ICustomerManager)Activator.GetObject(typeof(ICustomerManager), url);
>>>>>>
>>>>>>When I try to call a method on the cm instance I get an exception:
>>>>>>"Attempted to create a well-known object of type
>>>>>>ICustomerManager. Well known objects must derive from the
>>>>>>MarshalByRefObject."
>>>>>>
>>>>>>The implementation of the CustomerManager looks like this:
>>>>>>public class CustomerManager : MarshalByRefObject, ICustomerManager
>>>>>>{
>>>>>>...
>>>>>>}
>>>>>>
>>>>>>What am I doing wrong, I don't want do distribute my manager
>>>
>>>assemblies,
>>>
>>>
>>>>>but
>>>>>
>>>>>
>>>>>>just the interface assemblies?
>>>>>>
>>>>>>Thanks in advance!
>>>>>>/Henke
>>>>>>
>>>>>>
>>>>>
>>>>>
>>>
>
>

Henke

9/13/2004 8:22:00 PM

0

Hi, and thanks for your answers. Now it works!
But I have an other question.
For easier debugging I had a ObjectHandler that when in production 'creates'
the object by calling Activator.GetObject(typeof(CustomerManager), url), and
when in development

System.Reflection.Assembly a =
System.Reflection.Assembly.GetAssembly(CustomerManager);
object obj = a.CreateInstance(CustomerManager.ToString());

Now that I have changed to interfaces I can't use the CreateInstance method
anymore any good ideas about this problem?

/Henke

"Ken Kolda" <ken.kolda@elliemae-nospamplease.com> skrev i meddelandet
news:%23$Ui68bmEHA.748@TK2MSFTNGP15.phx.gbl...
> By using interface-based remoting no stub is necessary -- he just deploys
> the assembly containing the interface definition. Creating a stub via
> SoapSuds is alternative to using interfaces (although I've never seen the
> advantage to it).
>
> Ken
>
>
> "Robert Jordan" <robertj@gmx.net> wrote in message
> news:ci4o7r$t8u$03$1@news.t-online.com...
> > Ken Kolda wrote:
> >
> > > Ahh.. there's your problem. When you cann
RegisterWellKnownServiceType,
> you
> > > have to pass it a class Type, not an interface (after all, the
remoting
> > > framework has to know what type to instantiate to fulfill the remoting
> > > requests it receives). Just change your call to use CustomerMnager
> instead
> > > of ICustomerManager. From the client side, it will still just use
> > > ICustomerManager and does not need the CustomerManager implementation,
> so
> > > you've still achieved the separation you want.
> >
> > BTW, a stub implementation of CustomerManager can be generated
> > with SoapSuds.exe. You should always deploy the stub with the
> > clients instead of the real implementation.
> >
> > bye
> > Rob
> >
> >
> > >
> > > Ken
> > >
> > >
> > > "Henke" <henke_nord@hotmail.com> wrote in message
> > > news:eF3NBdamEHA.644@tk2msftngp13.phx.gbl...
> > >
> > >>Yes, here it is:
> > >>TcpChannel channel = new TcpChannel(2099);
> > >>ChannelServices.RegisterChannel(channel);
> > >>
> > >>
> > >
> > >
>
RemotingConfiguration.RegisterWellKnownServiceType(typeof(ICustomerManager),
> > >
> > >> "RemoteServer",
> > >> WellKnownObjectMode.SingleCall);
> > >>
> > >>/Henke
> > >>
> > >>"Ken Kolda" <ken.kolda@elliemae-nospamplease.com> skrev i meddelandet
> > >>news:%23RJGCVamEHA.3484@TK2MSFTNGP10.phx.gbl...
> > >>
> > >>>Can you show the server-side code you use to register the well-known
> > >>
> > >>object?
> > >>
> > >>>Ken
> > >>>
> > >>>
> > >>>"Henke" <henke_nord@hotmail.com> wrote in message
> > >>>news:%23FyuiyZmEHA.2020@TK2MSFTNGP09.phx.gbl...
> > >>>
> > >>>>Hi!
> > >>>>I have a 3-tier solution that uses remoting from the business logic
> > >>
> > >>layer
> > >>
> > >>>to
> > >>>
> > >>>>the data access layer. Every business manager object implements an
> > >>>
> > >>>interface
> > >>>
> > >>>>that is used by the ASP.NET clients to communicate with the business
> > >>>
> > >>>logic.
> > >>>
> > >>>>Ie I have a CustomerManager object and a ICustomerManager interface.
> > >>
> > >>Only
> > >>
> > >>>my
> > >>>
> > >>>>interface assembly is distributed with the client.
> > >>>>
> > >>>>I "create" my managers in the client by calling:
> > >>>>ICustomerManager cm
> > >>>>=(ICustomerManager)Activator.GetObject(typeof(ICustomerManager),
url);
> > >>>>
> > >>>>When I try to call a method on the cm instance I get an exception:
> > >>>>"Attempted to create a well-known object of type
> > >>>>ICustomerManager. Well known objects must derive from the
> > >>>>MarshalByRefObject."
> > >>>>
> > >>>>The implementation of the CustomerManager looks like this:
> > >>>>public class CustomerManager : MarshalByRefObject, ICustomerManager
> > >>>>{
> > >>>> ...
> > >>>>}
> > >>>>
> > >>>>What am I doing wrong, I don't want do distribute my manager
> > >
> > > assemblies,
> > >
> > >>>but
> > >>>
> > >>>>just the interface assemblies?
> > >>>>
> > >>>>Thanks in advance!
> > >>>>/Henke
> > >>>>
> > >>>>
> > >>>
> > >>>
> > >>
> > >
> > >
>
>


Robert Jordan

9/13/2004 8:48:00 PM

0

Hi Ken,

sorry, forget it. I obviosly didn't read the OP ;-)

bye
Rob

>> By using interface-based remoting no stub is necessary -- he just deploys
>> the assembly containing the interface definition. Creating a stub via
>> SoapSuds is alternative to using interfaces (although I've never seen the
>> advantage to it).
>
>
> Well, as you stated before: a class type is required to be able
> to instantiate the CAO, and that type must implemenent the
> certain interface. You have 2 choices: deploy the whole
> implementation (bad) or deploy the stubs.



>
> [Anyway, I'd go for the 3rd way: singleton with factory
> pattern]
>
> bye
> Rob
>
>
>>
>> Ken
>>
>>
>> "Robert Jordan" <robertj@gmx.net> wrote in message
>> news:ci4o7r$t8u$03$1@news.t-online.com...
>>
>>> Ken Kolda wrote:
>>>
>>>
>>>> Ahh.. there's your problem. When you cann RegisterWellKnownServiceType,
>>
>>
>> you
>>
>>>> have to pass it a class Type, not an interface (after all, the remoting
>>>> framework has to know what type to instantiate to fulfill the remoting
>>>> requests it receives). Just change your call to use CustomerMnager
>>
>>
>> instead
>>
>>>> of ICustomerManager. From the client side, it will still just use
>>>> ICustomerManager and does not need the CustomerManager implementation,
>>
>>
>> so
>>
>>>> you've still achieved the separation you want.
>>>
>>>
>>> BTW, a stub implementation of CustomerManager can be generated
>>> with SoapSuds.exe. You should always deploy the stub with the
>>> clients instead of the real implementation.
>>>
>>> bye
>>> Rob
>>>
>>>
>>>
>>>> Ken
>>>>
>>>>
>>>> "Henke" <henke_nord@hotmail.com> wrote in message
>>>> news:eF3NBdamEHA.644@tk2msftngp13.phx.gbl...
>>>>
>>>>
>>>>> Yes, here it is:
>>>>> TcpChannel channel = new TcpChannel(2099);
>>>>> ChannelServices.RegisterChannel(channel);
>>>>>
>>>>>
>>>>
>>>>
>> RemotingConfiguration.RegisterWellKnownServiceType(typeof(ICustomerManager),
>>
>>
>>>>> "RemoteServer",
>>>>> WellKnownObjectMode.SingleCall);
>>>>>
>>>>> /Henke
>>>>>
>>>>> "Ken Kolda" <ken.kolda@elliemae-nospamplease.com> skrev i meddelandet
>>>>> news:%23RJGCVamEHA.3484@TK2MSFTNGP10.phx.gbl...
>>>>>
>>>>>
>>>>>> Can you show the server-side code you use to register the well-known
>>>>>
>>>>>
>>>>> object?
>>>>>
>>>>>
>>>>>> Ken
>>>>>>
>>>>>>
>>>>>> "Henke" <henke_nord@hotmail.com> wrote in message
>>>>>> news:%23FyuiyZmEHA.2020@TK2MSFTNGP09.phx.gbl...
>>>>>>
>>>>>>
>>>>>>> Hi!
>>>>>>> I have a 3-tier solution that uses remoting from the business logic
>>>>>
>>>>>
>>>>> layer
>>>>>
>>>>>
>>>>>> to
>>>>>>
>>>>>>
>>>>>>> the data access layer. Every business manager object implements an
>>>>>>
>>>>>>
>>>>>> interface
>>>>>>
>>>>>>
>>>>>>> that is used by the ASP.NET clients to communicate with the business
>>>>>>
>>>>>>
>>>>>> logic.
>>>>>>
>>>>>>
>>>>>>> Ie I have a CustomerManager object and a ICustomerManager interface.
>>>>>
>>>>>
>>>>> Only
>>>>>
>>>>>
>>>>>> my
>>>>>>
>>>>>>
>>>>>>> interface assembly is distributed with the client.
>>>>>>>
>>>>>>> I "create" my managers in the client by calling:
>>>>>>> ICustomerManager cm
>>>>>>> =(ICustomerManager)Activator.GetObject(typeof(ICustomerManager),
>>>>>>> url);
>>>>>>>
>>>>>>> When I try to call a method on the cm instance I get an exception:
>>>>>>> "Attempted to create a well-known object of type
>>>>>>> ICustomerManager. Well known objects must derive from the
>>>>>>> MarshalByRefObject."
>>>>>>>
>>>>>>> The implementation of the CustomerManager looks like this:
>>>>>>> public class CustomerManager : MarshalByRefObject, ICustomerManager
>>>>>>> {
>>>>>>> ...
>>>>>>> }
>>>>>>>
>>>>>>> What am I doing wrong, I don't want do distribute my manager
>>>>
>>>>
>>>> assemblies,
>>>>
>>>>
>>>>>> but
>>>>>>
>>>>>>
>>>>>>> just the interface assemblies?
>>>>>>>
>>>>>>> Thanks in advance!
>>>>>>> /Henke
>>>>>>>
>>>>>>>
>>>>>>
>>>>>>
>>>>
>>
>>

Ken Kolda

9/13/2004 9:05:00 PM

0

You can still use CreateInstance(), just pass it the name of the class as a
literal string (instead of using Type.ToString()), e.g.

ICustomerManager mngr = (ICustomerManager)
assembly.CreateInstance("MyNamespace.CustomerManager");

Ken


"Henke" <henke_nord@hotmail.com> wrote in message
news:OYTWH%23cmEHA.3428@TK2MSFTNGP14.phx.gbl...
> Hi, and thanks for your answers. Now it works!
> But I have an other question.
> For easier debugging I had a ObjectHandler that when in production
'creates'
> the object by calling Activator.GetObject(typeof(CustomerManager), url),
and
> when in development
>
> System.Reflection.Assembly a =
> System.Reflection.Assembly.GetAssembly(CustomerManager);
> object obj = a.CreateInstance(CustomerManager.ToString());
>
> Now that I have changed to interfaces I can't use the CreateInstance
method
> anymore any good ideas about this problem?
>
> /Henke
>
> "Ken Kolda" <ken.kolda@elliemae-nospamplease.com> skrev i meddelandet
> news:%23$Ui68bmEHA.748@TK2MSFTNGP15.phx.gbl...
> > By using interface-based remoting no stub is necessary -- he just
deploys
> > the assembly containing the interface definition. Creating a stub via
> > SoapSuds is alternative to using interfaces (although I've never seen
the
> > advantage to it).
> >
> > Ken
> >
> >
> > "Robert Jordan" <robertj@gmx.net> wrote in message
> > news:ci4o7r$t8u$03$1@news.t-online.com...
> > > Ken Kolda wrote:
> > >
> > > > Ahh.. there's your problem. When you cann
> RegisterWellKnownServiceType,
> > you
> > > > have to pass it a class Type, not an interface (after all, the
> remoting
> > > > framework has to know what type to instantiate to fulfill the
remoting
> > > > requests it receives). Just change your call to use CustomerMnager
> > instead
> > > > of ICustomerManager. From the client side, it will still just use
> > > > ICustomerManager and does not need the CustomerManager
implementation,
> > so
> > > > you've still achieved the separation you want.
> > >
> > > BTW, a stub implementation of CustomerManager can be generated
> > > with SoapSuds.exe. You should always deploy the stub with the
> > > clients instead of the real implementation.
> > >
> > > bye
> > > Rob
> > >
> > >
> > > >
> > > > Ken
> > > >
> > > >
> > > > "Henke" <henke_nord@hotmail.com> wrote in message
> > > > news:eF3NBdamEHA.644@tk2msftngp13.phx.gbl...
> > > >
> > > >>Yes, here it is:
> > > >>TcpChannel channel = new TcpChannel(2099);
> > > >>ChannelServices.RegisterChannel(channel);
> > > >>
> > > >>
> > > >
> > > >
> >
>
RemotingConfiguration.RegisterWellKnownServiceType(typeof(ICustomerManager),
> > > >
> > > >> "RemoteServer",
> > > >> WellKnownObjectMode.SingleCall);
> > > >>
> > > >>/Henke
> > > >>
> > > >>"Ken Kolda" <ken.kolda@elliemae-nospamplease.com> skrev i
meddelandet
> > > >>news:%23RJGCVamEHA.3484@TK2MSFTNGP10.phx.gbl...
> > > >>
> > > >>>Can you show the server-side code you use to register the
well-known
> > > >>
> > > >>object?
> > > >>
> > > >>>Ken
> > > >>>
> > > >>>
> > > >>>"Henke" <henke_nord@hotmail.com> wrote in message
> > > >>>news:%23FyuiyZmEHA.2020@TK2MSFTNGP09.phx.gbl...
> > > >>>
> > > >>>>Hi!
> > > >>>>I have a 3-tier solution that uses remoting from the business
logic
> > > >>
> > > >>layer
> > > >>
> > > >>>to
> > > >>>
> > > >>>>the data access layer. Every business manager object implements an
> > > >>>
> > > >>>interface
> > > >>>
> > > >>>>that is used by the ASP.NET clients to communicate with the
business
> > > >>>
> > > >>>logic.
> > > >>>
> > > >>>>Ie I have a CustomerManager object and a ICustomerManager
interface.
> > > >>
> > > >>Only
> > > >>
> > > >>>my
> > > >>>
> > > >>>>interface assembly is distributed with the client.
> > > >>>>
> > > >>>>I "create" my managers in the client by calling:
> > > >>>>ICustomerManager cm
> > > >>>>=(ICustomerManager)Activator.GetObject(typeof(ICustomerManager),
> url);
> > > >>>>
> > > >>>>When I try to call a method on the cm instance I get an exception:
> > > >>>>"Attempted to create a well-known object of type
> > > >>>>ICustomerManager. Well known objects must derive from the
> > > >>>>MarshalByRefObject."
> > > >>>>
> > > >>>>The implementation of the CustomerManager looks like this:
> > > >>>>public class CustomerManager : MarshalByRefObject,
ICustomerManager
> > > >>>>{
> > > >>>> ...
> > > >>>>}
> > > >>>>
> > > >>>>What am I doing wrong, I don't want do distribute my manager
> > > >
> > > > assemblies,
> > > >
> > > >>>but
> > > >>>
> > > >>>>just the interface assemblies?
> > > >>>>
> > > >>>>Thanks in advance!
> > > >>>>/Henke
> > > >>>>
> > > >>>>
> > > >>>
> > > >>>
> > > >>
> > > >
> > > >
> >
> >
>
>


Henke

9/14/2004 6:36:00 AM

0

Ok, thanks Ken. I have to do a litle parsing method that parses my
interfaces to class names than.
/Henke

"Ken Kolda" <ken.kolda@elliemae-nospamplease.com> skrev i meddelandet
news:ugzskVdmEHA.2612@TK2MSFTNGP15.phx.gbl...
> You can still use CreateInstance(), just pass it the name of the class as
a
> literal string (instead of using Type.ToString()), e.g.
>
> ICustomerManager mngr = (ICustomerManager)
> assembly.CreateInstance("MyNamespace.CustomerManager");
>
> Ken
>
>
> "Henke" <henke_nord@hotmail.com> wrote in message
> news:OYTWH%23cmEHA.3428@TK2MSFTNGP14.phx.gbl...
> > Hi, and thanks for your answers. Now it works!
> > But I have an other question.
> > For easier debugging I had a ObjectHandler that when in production
> 'creates'
> > the object by calling Activator.GetObject(typeof(CustomerManager), url),
> and
> > when in development
> >
> > System.Reflection.Assembly a =
> > System.Reflection.Assembly.GetAssembly(CustomerManager);
> > object obj = a.CreateInstance(CustomerManager.ToString());
> >
> > Now that I have changed to interfaces I can't use the CreateInstance
> method
> > anymore any good ideas about this problem?
> >
> > /Henke
> >
> > "Ken Kolda" <ken.kolda@elliemae-nospamplease.com> skrev i meddelandet
> > news:%23$Ui68bmEHA.748@TK2MSFTNGP15.phx.gbl...
> > > By using interface-based remoting no stub is necessary -- he just
> deploys
> > > the assembly containing the interface definition. Creating a stub via
> > > SoapSuds is alternative to using interfaces (although I've never seen
> the
> > > advantage to it).
> > >
> > > Ken
> > >
> > >
> > > "Robert Jordan" <robertj@gmx.net> wrote in message
> > > news:ci4o7r$t8u$03$1@news.t-online.com...
> > > > Ken Kolda wrote:
> > > >
> > > > > Ahh.. there's your problem. When you cann
> > RegisterWellKnownServiceType,
> > > you
> > > > > have to pass it a class Type, not an interface (after all, the
> > remoting
> > > > > framework has to know what type to instantiate to fulfill the
> remoting
> > > > > requests it receives). Just change your call to use CustomerMnager
> > > instead
> > > > > of ICustomerManager. From the client side, it will still just use
> > > > > ICustomerManager and does not need the CustomerManager
> implementation,
> > > so
> > > > > you've still achieved the separation you want.
> > > >
> > > > BTW, a stub implementation of CustomerManager can be generated
> > > > with SoapSuds.exe. You should always deploy the stub with the
> > > > clients instead of the real implementation.
> > > >
> > > > bye
> > > > Rob
> > > >
> > > >
> > > > >
> > > > > Ken
> > > > >
> > > > >
> > > > > "Henke" <henke_nord@hotmail.com> wrote in message
> > > > > news:eF3NBdamEHA.644@tk2msftngp13.phx.gbl...
> > > > >
> > > > >>Yes, here it is:
> > > > >>TcpChannel channel = new TcpChannel(2099);
> > > > >>ChannelServices.RegisterChannel(channel);
> > > > >>
> > > > >>
> > > > >
> > > > >
> > >
> >
>
RemotingConfiguration.RegisterWellKnownServiceType(typeof(ICustomerManager),
> > > > >
> > > > >> "RemoteServer",
> > > > >> WellKnownObjectMode.SingleCall);
> > > > >>
> > > > >>/Henke
> > > > >>
> > > > >>"Ken Kolda" <ken.kolda@elliemae-nospamplease.com> skrev i
> meddelandet
> > > > >>news:%23RJGCVamEHA.3484@TK2MSFTNGP10.phx.gbl...
> > > > >>
> > > > >>>Can you show the server-side code you use to register the
> well-known
> > > > >>
> > > > >>object?
> > > > >>
> > > > >>>Ken
> > > > >>>
> > > > >>>
> > > > >>>"Henke" <henke_nord@hotmail.com> wrote in message
> > > > >>>news:%23FyuiyZmEHA.2020@TK2MSFTNGP09.phx.gbl...
> > > > >>>
> > > > >>>>Hi!
> > > > >>>>I have a 3-tier solution that uses remoting from the business
> logic
> > > > >>
> > > > >>layer
> > > > >>
> > > > >>>to
> > > > >>>
> > > > >>>>the data access layer. Every business manager object implements
an
> > > > >>>
> > > > >>>interface
> > > > >>>
> > > > >>>>that is used by the ASP.NET clients to communicate with the
> business
> > > > >>>
> > > > >>>logic.
> > > > >>>
> > > > >>>>Ie I have a CustomerManager object and a ICustomerManager
> interface.
> > > > >>
> > > > >>Only
> > > > >>
> > > > >>>my
> > > > >>>
> > > > >>>>interface assembly is distributed with the client.
> > > > >>>>
> > > > >>>>I "create" my managers in the client by calling:
> > > > >>>>ICustomerManager cm
> > > > >>>>=(ICustomerManager)Activator.GetObject(typeof(ICustomerManager),
> > url);
> > > > >>>>
> > > > >>>>When I try to call a method on the cm instance I get an
exception:
> > > > >>>>"Attempted to create a well-known object of type
> > > > >>>>ICustomerManager. Well known objects must derive from the
> > > > >>>>MarshalByRefObject."
> > > > >>>>
> > > > >>>>The implementation of the CustomerManager looks like this:
> > > > >>>>public class CustomerManager : MarshalByRefObject,
> ICustomerManager
> > > > >>>>{
> > > > >>>> ...
> > > > >>>>}
> > > > >>>>
> > > > >>>>What am I doing wrong, I don't want do distribute my manager
> > > > >
> > > > > assemblies,
> > > > >
> > > > >>>but
> > > > >>>
> > > > >>>>just the interface assemblies?
> > > > >>>>
> > > > >>>>Thanks in advance!
> > > > >>>>/Henke
> > > > >>>>
> > > > >>>>
> > > > >>>
> > > > >>>
> > > > >>
> > > > >
> > > > >
> > >
> > >
> >
> >
>
>