This message was discovered on microsoft.public.dotnet.framework.remoting.
| Henke |
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 |
Can you show the server-side code you use to register the well-known object?
Ken
"Henke" <Click here to reveal e-mail address> wrote in message news:%Click here to reveal e-mail address... [Original message clipped]
|
|
| |
| |
| Henke |
Yes, here it is: TcpChannel channel = new TcpChannel(2099); ChannelServices.RegisterChannel(channel);
RemotingConfiguration.RegisterWellKnownServiceType(typeof(ICustomerManager), "RemoteServer", WellKnownObjectMode.SingleCall);
/Henke
"Ken Kolda" <Click here to reveal e-mail address> skrev i meddelandet news:%Click here to reveal e-mail address... > Can you show the server-side code you use to register the well-known object? [Original message clipped]
|
|
| |
| |
| Ken Kolda |
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" <Click here to reveal e-mail address> wrote in message news:Click here to reveal e-mail address... [Original message clipped]
|
|
| |
| |
| Robert Jordan |
Ken Kolda wrote:
[Original message clipped]
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
[Original message clipped]
|
|
| |
| |
| Ken Kolda |
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" <Click here to reveal e-mail address> wrote in message news:ci4o7r$t8u$03$Click here to reveal e-mail address... [Original message clipped]
|
|
| |
| |
| Robert Jordan |
Hi Ken,
[Original message clipped]
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
[Original message clipped]
|
|
| |
| |
| Robert Jordan |
Hi Ken,
sorry, forget it. I obviosly didn't read the OP ;-)
bye Rob
[Original message clipped]
|
|
| |
|
|
| |
| Henke |
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" <Click here to reveal e-mail address> skrev i meddelandet news:%23$Click here to reveal e-mail address... [Original message clipped]
|
|
| |
| |
| Ken Kolda |
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" <Click here to reveal e-mail address> wrote in message news:OYTWH%Click here to reveal e-mail address... [Original message clipped]
|
|
| |
| | |
|
|
|
|
|
|
|
|
|
|
|