90 likes | 204 Views
This chapter provides an in-depth exploration of .NET Remoting, focusing on application domains, remote object types, and marshaling methods. Application domains serve as a bridge between managed and unmanaged code, allowing for efficient fault isolation and security while managing resources. Learn about marshaling-by-value and marshaling-by-reference, the significance of creating proxies, and how different channels (TCP, HTTP, IPC) facilitate communication between remote objects. Gain insights into the .NET Remoting architecture to enhance your application's performance and security.
E N D
Chapter 10 – Remoting CIS 330 - .NET Applications
Objectives • Application Domains • Remote Object Types • Marshaling-by-Reference Modes • The .NET Remoting Architecture CIS 330 - .NET Applications
Application Domains • All .NET components require a managed environment to run in • OS’s provide processes only • Application Domain: bridge between managed code and unmanged code (OS processes) Process A Process B App Domain A App Domain B App Domain C Assembly 1 Assembly 1 Assembly 1 Assembly 2 Assembly 4 Assembly 4 Assembly 3 Assembly 5 Assembly 6 CIS 330 - .NET Applications
Application Domains (cont) • App domain – logical processes • Why App Domains? • Fault Isolation • Security • Benefits • Lower overhead • Can start and shut down independent of hosting processes • Cross-app domain calls in same process are faster then cross-process calls CIS 330 - .NET Applications
Proxy Proxy Client Object Client Proxy Client Client Application Domains (cont) • All cross-app domains use remoting Machine 2 Machine 1 Process C Process A Process B App Domain 4 App Domain 1 App Domain 3 App Domain 2 Marshalling: forwarding a call to an object CIS 330 - .NET Applications
Application Domains (cont) • .NET has AppDomain class • CurrentDomain static property • Default App Domain: created when exe is launched • Can create objects in app domain • CreateInstanceAndUnwrap(…) • Can create new App Domain • CreateDomain(string friendlyName) • Can create proxy on client side • CreateInstance() & Unwrap() CIS 330 - .NET Applications
Remote Object Types • Marshaling by Value • Copy of object is transferred to calling app domain • Objects must be serializable • Used when client makes frequent short calls • Marshaling by Reference • Remote object accessed via proxy • Class must be derived from MarshalByRefObject • Two kinds: client-activated and server-activated CIS 330 - .NET Applications
Client Object Proxy Formatter Channel Channel Formatter .NET Remoting Architecture Client App Domain • Formatter: SOAP or binary • Channel: TCP, HTTP, or IPC • Both client and host must do channel registration MethodCall() Message MethodCall() Message Stack Builder Host App Domain CIS 330 - .NET Applications
Summary • Application Domains • Remote Object Types • Marshaling-by-Reference Modes • The .NET Remoting Architecture CIS 330 - .NET Applications