Fairly simple .NET Remoting scenario but problematic [modified]
-
Hi, I implemented this simple scenario containing 3 assemblies: - TL (Transport Layer) assembly that contains only one class 'Class1':
public class Class1 : MarshalByRefObject { public int MyProperty { get; set; } }
and one interface:public interface Interface1 { Class1 Get(int i); }
- BLL (Business Logic Layer) application that will act as a server in my remoting scenario. This assembly has reference to TL assembly and contains 2 files: BLL Manager:class BLLManager : Interface1 { public Class1 Get(int i) { return new Class1() { MyProperty = i - 1 }; } }
And an xml file: <?xml version="1.0" encoding="utf-8" ?><configuration> <system.runtime.remoting> <application> <channels> <channel ref = "tcp" port = "5001" /> </channels> <service> <wellknown mode = "SingleCall" type = "TL, Interface1" objectUri = "Uri1" /> </service> </application> </system.runtime.remoting></configuration> The BLL assembly is a Windows Service. In the OnStart method I included the following code:protected override void OnStart(string[] args) { RemotingConfiguration.Configure(@"C:\somefolder\BLL\bin\Debug\Config.xml", false); }
I installed this service and started it. Third assembly is a simple Web application that acts as a .NET Remoting client here; it contains reference to TL as well. This assembly contains config file 'Web.config': <?xml version="1.0"?>... <system.runtime.remoting> <application> <client> <wellknown type = "TL.Interface1, Uri1" url="tcp://lsrv01:5001/BLL" /> < </client> <channels> <channel ref="tcp" port="0"/> </channels> </application> </system.runtime.remoting></configuration> It also contains Default.aspx, which has the following C# code:RemotingConfiguration.Configure(@"C:\/*some path*/\Web.config", false); Interface1 obj = (Interface1)Activator.GetObject(typeof(Interface1), "tcp://lsrv01:5001/BLL"); var i = obj.Get(5);
However I`m getting RemoteException in the last line. It say: "Server encountered an internal error. For more information, turn off customErrors in the server's .config file." In my web application I modified the web.config file accordingly: <authentication mode="Windows"/> <customErrors mode="Off" defaultRedirect="GenericErrorPage.htm"> <error statusCode="403" r -
Hi, I implemented this simple scenario containing 3 assemblies: - TL (Transport Layer) assembly that contains only one class 'Class1':
public class Class1 : MarshalByRefObject { public int MyProperty { get; set; } }
and one interface:public interface Interface1 { Class1 Get(int i); }
- BLL (Business Logic Layer) application that will act as a server in my remoting scenario. This assembly has reference to TL assembly and contains 2 files: BLL Manager:class BLLManager : Interface1 { public Class1 Get(int i) { return new Class1() { MyProperty = i - 1 }; } }
And an xml file: <?xml version="1.0" encoding="utf-8" ?><configuration> <system.runtime.remoting> <application> <channels> <channel ref = "tcp" port = "5001" /> </channels> <service> <wellknown mode = "SingleCall" type = "TL, Interface1" objectUri = "Uri1" /> </service> </application> </system.runtime.remoting></configuration> The BLL assembly is a Windows Service. In the OnStart method I included the following code:protected override void OnStart(string[] args) { RemotingConfiguration.Configure(@"C:\somefolder\BLL\bin\Debug\Config.xml", false); }
I installed this service and started it. Third assembly is a simple Web application that acts as a .NET Remoting client here; it contains reference to TL as well. This assembly contains config file 'Web.config': <?xml version="1.0"?>... <system.runtime.remoting> <application> <client> <wellknown type = "TL.Interface1, Uri1" url="tcp://lsrv01:5001/BLL" /> < </client> <channels> <channel ref="tcp" port="0"/> </channels> </application> </system.runtime.remoting></configuration> It also contains Default.aspx, which has the following C# code:RemotingConfiguration.Configure(@"C:\/*some path*/\Web.config", false); Interface1 obj = (Interface1)Activator.GetObject(typeof(Interface1), "tcp://lsrv01:5001/BLL"); var i = obj.Get(5);
However I`m getting RemoteException in the last line. It say: "Server encountered an internal error. For more information, turn off customErrors in the server's .config file." In my web application I modified the web.config file accordingly: <authentication mode="Windows"/> <customErrors mode="Off" defaultRedirect="GenericErrorPage.htm"> <error statusCode="403" rOne of the reasons that .NET remoting is no longer used is because even the simplest remoting problem was complex to implement. It took me almost a year to become a remoting expert. Much of the remoting elements within the framework are also Obsolete. I would suggest you deploy your service as a wcf service, then the rest is a very simple process. In your web application all you need to do is Add Web Service and you are running. You can host the service in iis or bind it to whatever protocol you want. An advantage of WCF over Remoting is that you control the entire service config with an editor and attributes. You can build new wcf services and bind to them in a day without the headaches you are experiencing. As it is, once I started using WCF I completely let go of all memory of remoting. If you find you need to change protocols or bindings, it is a simple matter of changing attributes without changing any code. Use WCF and forget about remoting ever existing.