Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Fairly simple .NET Remoting scenario but problematic [modified]

Fairly simple .NET Remoting scenario but problematic [modified]

Scheduled Pinned Locked Moved C#
csharpsysadminsecuritydebuggingbusiness
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • Y Offline
    Y Offline
    Yoyosch
    wrote on last edited by
    #1

    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

    M 1 Reply Last reply
    0
    • Y Yoyosch

      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

      M Offline
      M Offline
      Michael J Eber
      wrote on last edited by
      #2

      One 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.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups