-
Notifications
You must be signed in to change notification settings - Fork 22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Derive from MarshalByRefObject throws not serializable exception #46
Comments
Hi AlleSchonWeg, when decorating TestClass with [Serializable], a serialized copy is sent to client, not a reference. On client side a new instance is deserialized. What you expect is automatic creation of a proxy on client side that refers to the remote TestClass instance. MarshalByRefObj inheritance is ignored by CoreRemoting. In CoreRemoting, it is not the base class that is decisive for remote accessibility, but whether the type is registered as a service on the server side. CoreRemoting is not an exact clone of classic .NET Remoting. Some concepts are different. It is not possible in CoreRemoting to return an object by reference, that is not registered as service. A service must implement an interface. In CoreRemoting a proxy can only be created for interfaces, not for classes. This is a limitation of the Castle.DynamicProxy, which is used internally to create proxies. A service must be registered with an interface. |
Hi, |
Hi AlleSchonWeg, yes, but using such proxy chains tends not to lead to a clean, evolvable and performant software architecture, To get this behavior in CoreRemoting up and running, every object used in the chain must be registered as service at the DI container. A service needs an interface (Castle.DynamicProxy cannot create proxies for classes, but only for interface). To select the right interface, the interface may be provided by an attribute. This attribute could be used as replacement for MarshalByRefObject. To allow registration of different instances of the same interface, the services must be registered with an unique name. The name must be generated (maybe a hash). I don't think it's worth the effort. |
Describe the bug
Hi,
i have to migrate a very big client server app from .Net Framework 4.8 to .Net 7. This app communicate via .Net Remoting. I have extended your examples to test some things, which works in TaskDemoAppNetRemoting but not in MigratedTaskDemoAppNetRemoting.
To Reproduce
Create new class in Shared Project:
In TodoService add property and create object from TestClasss:
Extend interface ITodoService:
Call GetData from Client:
The call throws an exception:
Expected behavior
No exception should happen. Same code in the .Net Remoting example runs fine.
The expected behavior is, that _
todoServiceProxy.MyProp.GetData();
is called on the server, because TestClass in derived from MarshalByRefObject.AppDomain.CurrentDomain.FriendlyName
should be MigratedTaskDemoAppNetRemoting.Server.Additional notes
If the SerializableAttribute was added:
then it works as expected. The call _
todoServiceProxy.MyProp.GetData();
returns MigratedTaskDemoAppNetRemoting.Client.The text was updated successfully, but these errors were encountered: