Home > Articles

.NET Remoting

This chapter is from the book

Apply Your Knowledge

Exercises

3.1 - Using HTTP Channels with Binary Formatters

As I discussed in the chapter, the default formatter for an HTTP channel is SOAP and for a TCP channel is Binary. The formatters are used for serializing and deserializing messages in the specified encoding.

The chapter has made use of these default formatters in the examples. In this exercise, you'll learn how to configure a channel to use a formatter different from the default one.

In particular, I'll demonstrate how to use the binary formatter with the HTTP channel. This combination is especially useful when you want to optimize the performance of a remote object that is hosted on IIS. However, you should note that binary format is proprietary to the .NET Framework.

Estimated Time: 30 minutes.

  1. Launch Visual Studio .NET. Select File, New, Blank Solution, and name the new solution 310C03Exercises. Click OK.

  2. Add a new Empty Web Project named Exercise3-1_Server to the solution.

  3. Add references to StepByStep3-9.dll (the interface assembly containing IDbConnect) and StepByStep3-10.dll (the remotable object, DbConnect) from the 310C03 solution. You'll need to use the Browse button in the Add Reference dialog box to locate these libraries.

  4. Add a new Web Configuration File to the project. Open the web.config file and add the following <system.runtime.remoting> element inside the <configuration> element:

  5. <configuration>
      <system.runtime.remoting>
        <application>
          <service>
            <!-- Set the
               activation mode,
               remotable object
               and its URL -->
            <wellknown mode="Singleton"
              type="StepByStep3_10.DbConnect, StepByStep3_10"
              objectUri=
              "DbConnect.rem" />
          </service>
        </application>
      </system.runtime.remoting>
    ...
    </configuration>
  6. IIS is now hosting the StepByStep3-10.DbConnect, the remotable class, as a server activated object using the Singleton activation mode.

  7. Add a new Visual Basic .NET Windows Application named Exercise3-1_Client to the solution.

  8. Add a reference to StepByStep3_9.dll (the interface assembly containing IDbConnect).

  9. In the Solution Explorer, right-click project Exercise3_1_Client and select Add, Add New Item from the context menu. Add an Item named Exercise3-1_Client.exe.config based on the XML File Template.

  10. Open the Exercise3_1_Client.exe.config file and modify it to contain the following code:

  11. <configuration>
      <system.runtime.remoting>
        <application>
          <channels>
            <channel ref="http">
              <serverProviders>
                <formatter ref =
                 "binary" />
              </serverProviders>
            </channel>
          </channels>
        </application>
      </system.runtime.remoting>
    </configuration>
  12. In the Solution Explorer, select the project and click the Show All Files button in the toolbar. Move the Exercise3-1_Client.exe.config file from the project folder to the bin folder under the project, where the Exercise3-1_Client.exe file will be created when the project is compiled.

  13. In the Solution Explorer, delete the default Form1.vb. Add a new form named DbConnectClient.vb and set it as the startup object for the project.

  14. Place two GroupBox controls (grpQuery and grpResults), a TextBox control (txtQuery), a Button control (btnExecute), and a DataGrid control (dgResults) on the form. Set the Multiline property of txtQuery to True. Refer to Figure 3.5 for the design of this form.

  15. Add the following directives:

  16. Imports System.Runtime.Remoting
    Imports StepByStep3_9
  17. Add the following code directly after the Windows Form designer generated code:

  18. ' Declare a Remote object
    Dim dbc As IDbConnect
  19. Double-click the form and add the following code in the Load event handler:

  20. Private Sub DbConnectClient_Load( _
     ByVal sender As System.Object, _
     ByVal e As System.EventArgs) _
     Handles MyBase.Load
      ' Load remoting configuration
      RemotingConfiguration.Configure( _
       "Exercise3-1_Client.exe.config")
    
      ' Instantiate the remote class
      dbc = CType( _
       Activator.GetObject( _
       GetType(IDbConnect), _
       "http://localhost/Exercise3-1_Server/DbConnect.rem"), IDbConnect)
    End Sub
  21. Double-click the Button control and add the following code in the Click event handler:

  22. Private Sub btnExecute_Click( _
     ByVal sender As System.Object, _
     ByVal e As System.EventArgs) _
     Handles btnExecute.Click
      Try
        ' Invoke a method on
        ' the remote object
        Me.dgResults.DataSource = _
         dbc.ExecuteQuery(Me.txtQuery.Text)
        dgResults.DataMember = "Results"
      Catch ex As Exception
        MessageBox.Show(ex.Message, _
        "Query Execution Error")
      End Try
    End Sub
  23. Build the project. Set the Exercise3-1_Client, the remoting client, as the startup project. Select Debug, Start Without Debugging to run the project. Enter a query in the text box and click the button. The code invokes a method on the remote object. The remote object is serialized and deserialized in binary format and is transported over the HTTP protocol. The code binds the results from the remote method to the DataGrid control.

Note that you should always configure the client to use the binary formatter when configuring the server (IIS) to use the binary formatter. You can specify the desired formatter for the client and need not specify the channel formatter for the server. The formatter requested by the client will be used to format data by the server for that client.

3.2 - Dynamically Publishing a WellKnown Object

WellKnown objects cannot be invoked from a client with a non-default constructor. You can create an object using any constructor you wish, initialize it anyway you wish, and then make it available to clients.

Use RemotingServices.Marshal() to publish an existing object instance.

Estimated Time: 30 minutes.

  1. Add a new Visual Basic .NET Console Application named Exercise3-2_Server to the solution.

  2. Add references to .NET assembly System.Runtime.Remoting, the StepByStep3-9.dll (the interface assembly containing IDbConnect), and StepByStep3-10.dll (the remotable object, DbConnect).

  3. In the Solution Explorer, rename the default Module1.vb to DbConnectServer.vb. Open the file and change the name of the module to DbConnectServer in the module declaration. Set this new module to be the Startup object for the project.

  4. Add the following directives:

  5. Imports System.Runtime.Remoting
    Imports System.Runtime.Remoting.Channels
    Imports System.Runtime.Remoting. _
     Channels.Tcp
    Imports StepByStep3_10
  6. Add the following code in the Main() method:

  7. Sub Main()
      ' Create and Register a
      ' TCP server channel
      ' that listens on port
      Dim channel As TcpServerChannel = _
       New TcpServerChannel(1234)
      ChannelServices.RegisterChannel( _
       channel)
    
      ' Create the remotable
      ' object here itself
      ' Call the RemotingServices.Marshal()
      ' method
      ' to marshal (serialize)
      ' the created remotable
      ' object to transfer the
      ' object beyond application
      ' boundaries with the specified uri
      Dim dbcPubs As DbConnect = _
       New DbConnect("Pubs")
      RemotingServices.Marshal( _
       dbcPubs, "Pubs.uri")
    
      Dim dbcNorthwind As DbConnect = _
       New DbConnect("Northwind")
      RemotingServices.Marshal( _
       dbcNorthwind, "Northwind.uri")
    
      Console.WriteLine( _
       "Started server in the " & _
       "Singleton mode")
      Console.WriteLine( _
       "Press <ENTER> to terminate " & _
       "server...")
      Console.ReadLine()
    End Sub
  8. Build the project. This step creates a remoting server that creates the remotable object StepByStep3_10.DbConnect and is capable of marshalling the remote object across application boundaries.

  9. Add a new Visual Basic .NET Windows Application named Exercise3-2_Client to the solution.

  10. Add references to the .NET assembly System.Runtime.Remoting, and the project StepByStep3-9 (the interface assembly).

  11. In the Solution Explorer, delete the default Form1.vb. Add a new form named DbConnectClient.vb and set it as the startup object for the project.

  12. Add the following directives:

  13. Imports System.Runtime.Remoting
    Imports System.Runtime.Remoting.Channels
    Imports System.Runtime.Remoting. _
     Channels.Tcp
    Imports StepByStep3_9
  14. Place three GroupBox controls (grpDatabases, grpQuery and grpResults), a ComboBox control (cboDatabases), a TextBox control (txtQuery), a Button control (btnExecute), and a DataGrid control (dgResults) on the form. Set the DropDownStyle to DropDownList.

  15. Select the Items property of the cboDatabases control in the Properties window and click on the (...) button. This opens the String Collection Editor dialog box. Enter the following names of databases in the editor:

    Northwind
    Pubs

    Click OK to add the databases to the Items collection of the cboDatabases control.

  16. Add the following code directly after the Windows Form designer generated code:

  17. ' Declare a Remote object
    Dim dbc As IDbConnect
  18. Double-click the form and add the following code in the Load event handler:

  19. Private Sub DbConnectClient_Load( _
     ByVal sender As System.Object, _
     ByVal e As System.EventArgs) _
     Handles MyBase.Load
      ' Register a TCP client channel
      Dim channel As TcpClientChannel = _
       New TcpClientChannel()
      ChannelServices.RegisterChannel( _
       channel)
    
      cboDatabases.SelectedIndex =
    End Sub
  20. Double-click the cboDatabases control and add the following code in the SelectedIndexChanged event handler:

  21. Private Sub _
     cboDatabases_SelectedIndexChanged( _
     ByVal sender As System.Object, _
     ByVal e As System.EventArgs) _
     Handles cboDatabases.SelectedIndexChanged
      Select Case cboDatabases. _
       SelectedItem.ToString()
        Case "Pubs"
          ' Instantiate the remote class
          dbc = CType( _
          Activator.GetObject( _
           GetType(IDbConnect), _
          "tcp://localhost:1234/Pubs.uri"), IDbConnect)
        Case "Northwind"
          ' Instantiate the remote class
          dbc = CType( _
          Activator.GetObject( _
           GetType(IDbConnect), _
          "tcp://localhost:1234/Northwind.uri"), _
          IDbConnect)
      End Select
    End Sub
  22. Double-click the btnExecute control and add the following code in the Click event handler:

  23. Private Sub btnExecute_Click( _
     ByVal sender As System.Object, _
     ByVal e As System.EventArgs) _
     Handles btnExecute.Click
      Try
        ' Invoke a method on
        ' the remote object
        Me.dgResults.DataSource = _
         dbc.ExecuteQuery(Me.txtQuery.Text)
        dgResults.DataMember = "Results"
      Catch ex As Exception
        MessageBox.Show(ex.Message, _
         "Query Execution Error")
      End Try
    End Sub
  24. Build the project. You now have a remoting client ready to use.

  25. Set the Exercise3-2_Server, the CAO remoting server, as the startup project. Select Debug, Start Without Debugging to run the project. You should see a command window displaying a message that the server is started in the Singleton mode. You should also see messages that the remote object is already created.

  26. Now, set Exercise3_2_Client, the remoting client, as the startup project. Select Debug, Start Without Debugging to run the project. Select a desired database from the combo box, enter a query in the text box, and click the button. The code invokes a method on the remote object that is already created on the server. The code binds the results from the remote method to the DataGrid control.

  27. Now, again select Debug, Start Without Debugging to run one more instance of the remoting client. Select a different database from the combo box, enter a query in the text box, and click the button. You should see that the second instance of the client fetches the data from the selected database.

Review Questions

  1. What is an application domain? How does the CLR manage an application domain?

  2. What are MBR objects? What are their advantages?

  3. What is a channel? What are the different types of channels provided by the .NET Framework?

  4. What are the advantages and disadvantanges of the Binary and SOAP formatters?

  5. What are the two modes to create Server-Activated objects?

  6. When should you choose to create a Client-Activated object?

  7. What is the benefit of using declarative configuration over programmatic configuration?

  8. What are the two methods of the Activator class that allow you to create instances of remote objects?

  9. What are the advantages of using IIS server as an activation agent?

  10. What should you do while creating a remotable class so that its methods can be called asynchronously?

Exam Questions

  1. You are designing a distributed application that hosts a remote object. You want only the authorized client application to be capable of activating the remote object. You want to write the application with a minimum amount of code. Which of the following channels enables you to achieve this objective? (Select two choices.)

    1. HttpChannel

    2. HttpServerChannel

    3. TcpChannel

    4. TcpServerChannel

  2. You are designing a company-wide order processing system. This application is hosted on a server in the company's headquarters in Redmond, WA and is accessed by 1500 franchise locations throughout the world. The application specification mentions that the franchisees should be able to access the order-processing system even through the firewalls. A large number of franchisees access the application over a slow connection, and your objective is to maximize the performance of the application. Which of the following channel and formatter combinations would you choose in this scenario?

    1. Use a TCP channel with a binary formatter

    2. Use a TCP channel with a SOAP formatter

    3. Use an HTTP channel with a binary formatter

    4. Use an HTTP channel with a SOAP formatter

  3. You are designing a distributed application for a large automotive company. The application allows the part suppliers across the globe to collect the latest design specifications for a part. The application is heavily accessed by the suppliers. For greater scalability, you are required to design the application so that it can be deployed in a load-balanced environment. How should you host the remotable object in this scenario?

    1. As a server-activated object in SingleCall activation mode

    2. As a server-activated object in Singleton activation mode

    3. As a client-activated object using the HTTP channel

    4. As a client-activated object using the SOAP formatter

  4. You have been hired by Great Widgets Inc. to create an application that allows their supplier to access the purchase order information in real time. You create the required classes that can be activated remotely by the suppliers and package them into a file named gwpoinfo.dll. You plan to host this file using IIS as the remoting host. Your goal is that after the application has been deployed, there should be minimal steps involved to change the remoting configuration for this application. Also, any configuration changes made to the purchase order information system should not affect any other applications running on that server. Which of the following files would you choose to configure remoting for the purchase order information system?

    1. gwpoinfo.dll

    2. web.config

    3. global.asax

    4. machine.config

  5. You have designed a remotable class named ProductDesign. You now want to register this class with the remoting system in such a way that the client program should be able to remotely instantiate objects of this class and invoke methods on it. You want there to be only one instance of this class on the server irrespective of the number of clients connected to it. Which of the following code snippets fulfills your requirement?

    1. RemotingConfiguration. _
       RegisterWellKnownServiceType( _
       GetType(ProductDesign), _
       "ProductDesign", _   
       WellKnownObjectMode.SingleCall)
    2. RemotingConfiguration. _
       RegisterWellKnownServiceType(  _
       GetType(ProductDesign), _
       "ProductDesign", _   
       WellKnownObjectMode.Singleton)
    3. RemotingConfiguration. _
       RegisterActivatedServiceType(  _
       GetType(ProductDesign), _
       "ProductDesign")
    4. RemotingConfiguration. _
       RegisterWellKnownClientType( _
       GetType(ProductDesign), _
       "ProductDesign")
  6. You have designed a remotable class that allows the user to retrieve the latest weather information for her region. You do not want to write a lot of code to create a custom remoting host, so you decide to host the application using IIS. The name of the remotable class is RemotingWeather.WeatherInfo, and it is stored in an assembly named WeatherInfo.dll. You want the users to access this remotable class using the URL http://RemoteWeather.com/users/WeatherInfo.rem. Which of the following remoting configurations would you place in the web.config file so that client applications can correctly retrieve weather information?

    1. <system.runtime.remoting>
        <application>
          <service>
            <activated type=
             "RemotingWeather.WeatherInfo,
             WeatherInfo"
            />
         </service>
         <channels>
            <channel ref="http" port="80" />
         </channels>
        </application>
      </system.runtime.remoting>
    2. <system.runtime.remoting>
        <application>
          <service>
            <wellknown
            mode="Singleton" type=
             "RemotingWeather.WeatherInfo,
             WeatherInfo"
             objectUri="WeatherInfo.rem"
            />
         </service>
        </application>
      </system.runtime.remoting> 
    3. <system.runtime.remoting>
        <application>
          <service>
            <activated type=
             "RemotingWeather.WeatherInfo,
             WeatherInfo"
            />
         </service>
         <channels>
            <channel ref="http server"
            port="80" />
         </channels>
        </application>
      </system.runtime.remoting>
    4. <system.runtime.remoting>
        <application>
          <client>
            <wellknown
            mode="Singleton" type=
             "RemotingWeather.WeatherInfo,
             WeatherInfo"
             objectUri="WeatherInfo.rem"
            />
         </client>
        </application>
      </system.runtime.remoting> 
  7. You are a software developer for LubriSol Inc., which manufactures chemicals for automobile industries. Your company does major business with ReverseGear Inc., which is the largest manufacturer of heavy vehicles in the country. ReverseGear, Inc. uses a .NET remoting application that allows its suppliers to check the daily parts requirements. Your objective is to create a client application to the ReverseGear, Inc.'s application that retrieves the information for parts produced by your company. All you know about the server application is its URL, which is http://ReverseGearInc.com/Suppliers/Req.rem. You want the quickest solution. What should you do in order to successfully write a client application?

    1. Contact ReverseGear, Inc. to ask for the interface and include references to the interface in the client project.

    2. Open the URL in the Web browser and select View, Source to find out how the remote class is structured.

    3. Use the Visual Studio .NET Add Web Reference feature to add a reference to the remote class in the client project.

    4. Use the soapsuds tool to automatically generate the metadata and include the reference to this metadata in the client project.

  8. You want to host a remotable class via the .Net remoting framework so that remote clients can instantiate the class and invoke methods on it. The remotable class does not have any user interface, but it must use Integrated Windows authentication to authenticate the users. Which of the following techniques should you use to host the remotable class? You want a solution that requires you to write minimum code.

    1. Use a console application as a remoting host.

    2. Create a Windows service and use that to host the remotable class.

    3. Use a Windows forms application to host the remotable class.

    4. Use Internet Information Services (IIS) as a remoting host.

  9. You are developing a remoting client to access a server-activated remotable object hosted at the URL tcp://finance:1234/Budget. You have obtained an interface assembly of this remote object. This assembly contains an interface named IBudget that is implemented by the remote class. You want to instantiate the remote object to invoke a method named GetDepartmentBudget() that accepts a string value and returns a double value containing the department budget. Given the following code, what should you write in line 08 in order to successfully invoke the GetDepartmentBudget() method? Line numbers are for reference only.

    01: ' Register a TCP client channel
    02: Dim channel As TcpClientChannel = _
    03: New TcpClientChannel()
    04: ChannelServices. _
    05: RegisterChannel(channel)
    06: Dim budget As IBudget
    07: ' Instantiate the remote class
    08:
    09: ' Invoke the remote method
    10: Dim budgetValue As Double = _
    11: budget.GetDepartmentBudget("HR")
    1. budget = CType( _
       Activator.GetObject(GetType(IBudget), _
       "tcp://finance:1234/Budget"), IBudget)
    2. budget = CType( _
       Activator.CreateInstance( _
       GetType (IBudget), _
       "tcp://finance:1234/Budget"), IBudget)
    3. budget = New IBudget()
    4. RemotingConfiguration. _
       RegisterWellKnownClientType( _
       GetType (IBudget), _
       "tcp://finance:1234/Budget")
      Budget = new IBudget()
  10. You are developing an application that enables client programs to instantiate a class named Inventory. You want the remote object to be created on the server so that it can access the inventory database. However, you want client programs to have control of the creation and the lifetime of the remote objects. Which of the following methods of the RemotingConfiguration class would you choose to register the remotable class with the remoting system on the server?

    1. RegisterWellKnownServiceType()

    2. RegisterWellKnownClientType()

    3. RegisterActivatedServiceType()

    4. RegisterActivatedClientType()

  11. You work for a large chemical manufacturing company that has four production units across the country. Your team has the responsibility of designing a distributed application that allows different production units to share and update material safety information for various products. One of your co-workers is creating a remoting host to host a server-activated object using the following code, but she is getting an error. What should she do to resolve this error?

    01: Imports System.Runtime.Remoting
    02: Imports System.Runtime. _
    03: Remoting.Channels
    04: Imports System.Runtime.Remoting. _
    05: Channels.Tcp
    06: Imports System.Runtime.Remoting. _
    07: Channels.Http
    08:
    09: Sub Main()
    10:   ' Create and Register channels
    11:  Dim tcpChannel _
    12:    As TcpServerChannel = _
    13:    New TcpServerChannel(7777)
    14:  Dim httpChannel As _
    15:    HttpServerChannel = _
    16:    New HttpServerChannel(8888)
    17:  RemotingConfiguration. _
    18:     RegisterWellKnownServiceType _
    19:     (GetType(MsdsInfo), _
    20:    "MsdsInfo", _
    21:     WellKnownObjectMode.Singleton)
    22: End Sub
    1. Remove the statement in lines 14 through 16.

    2. Add the following statements just before line 17:

      ChannelServices.RegisterChannel(tcpChannel)
      ChannelServices.RegisterChannel( _
       httpChannel)
    3. In the statement in lines 11 through 13, replace TcpServerChannel with TcpChannel and similarly in the statement in lines 14 through 16, replace HttpServerChannel with HttpChannel.

    4. Use same port numbers in the statements in line 13 and line 16.

  12. One of your co-workers has written the following code as part of a client application that activates a remote object. She is complaining that her program is not compiling. What should she modify in the program to remove this error? (Select all that apply.)

    01: Function CreateObject() As DbConnect
    02:   ' Create channel
    03:   Dim channel As TcpClientChannel = _
    04:     new TcpClientChannel(1234)
    05:   ChannelServices.RegisterChannel( _
    06:   channel)
    07:   RemotingConfiguration. _
    08:   RegisterWellKnownClientType( _
    09:    GetType(DbConnect), _
    10:   "tcp://localhost/DbConnect")
    11:    
    12:   dbc = new DbConnect()
    13:   return dbc
    14: End Function
    1. Change line 8 to use the RegisterWellKnownServiceType() method instead of the RegisterWellKnownClientType() method.

    2. Change the URL in line 10 to "tcp://localhost:1234/DbConnect".

    3. Remove the port number from the constructor of TcpClientChannel() in line 4.

    4. Change the code in line 10 to objectUri="DbConnect".

  13. The soapsuds tool (soapsuds.exe) can be used to automatically generate the interface assembly for the remotable object. Which of the following statements related to the soapsuds tool are FALSE? (Select two options.)

    1. The soapsuds tool can be used to generate metadata for server-activated objects.

    2. The soapsuds tool can be used to generate metadata for client-activated objects.

    3. The soapsuds tool can be used to generate metadata for remotable objects registered through the HTTP channel.

    4. The soapsuds tool can be used to generate metadata for remotable objects registered through the TCP channel.

  14. You have designed a Windows application that is used by the shipping department of a large distribution house. The Windows application instantiates a remotable class hosted on Internet Information Services (IIS). The remotable class provides various services to the Windows application such as address validation and calculation of shipping rates. When you deploy the application, users complain that when they click the button named Validate Address, the windows application freezes and they can't take further actions until the address has been verified. What should you do to improve the responsiveness of the application?

    1. Use the binary formatter instead of the SOAP formatter.

    2. Use the TCP channel to communicate instead of the HTTP channel.

    3. Modify the remotable class to support asynchronous method calls.

    4. Modify the Windows application to call the methods asynchronously on the remote object.

  15. When you derive a class from MarshalByRefObject to make the class remotable, which of the following members of the class are not remoted? (Select all that apply.)

    1. Non-static public methods

    2. Static methods

    3. Non-static private methods

    4. Non-static public properties

Answers to Review Questions

  1. The application domain, or AppDomain, is the basic unit of isolation for running applications in the CLR. The CLR allows several application domains to run within a single Windows process. The CLR ensures that code running in one application domain cannot affect other application domains. The CLR can terminate an application domain without stopping the entire process.

  2. MBR objects are remotable objects that derive from the System.MarshalByRefObject class. MBR objects always reside on the server. The client application domain only holds a reference to MBR objects and uses a proxy object to interact with MBR objects. They are best suited when the remotable objects are large or when the functionality of the remotable objects is only available in the server environment on which it is created. However, they increase the number of network roundtrips between the server application domain and the client application domain.

  3. A channel is an object that transports messages across remoting boundaries such as application domains, processes, and computers. The .NET Framework provides implementations for HTTP and TCP channels.

  4. The Binary formatter represents messages in a compact and efficient way, whereas the SOAP formatter is very verbose. The SOAP formatter can be used to communicate in heterogenous environments, whereas the binary formatter can be understood only by the .NET applications.

  5. The two modes to create SAO are SingleCall and Singleton. SingleCall activation mode creates a remote object for each client request. The object is discarded as soon as the request completes. Singleton activation mode creates a remote object only once, and all the clients share the same copy. Hence, SingleCall SAOs are stateless, and Singleton SAOs maintain state global to all clients.

  6. CAO are created for each client whenever the client requests. Hence, CAOs are best suited when clients want to maintain private session with remote objects, when the clients want to control the lifetime of the objects, or when they want to create a customized remote object with non-default properties.

  7. The main benefit of using declarative configuration over programmatic configuration is that you need not recompile the application after changing the remoting settings in the configuration file. The changes are picked up automatically.

  8. The GetObject() (for server-activated objects) and CreateInstance() (for client-activated objects) methods are the two methods of Activator class that allow you to create instances of the remote objects.

  9. Using IIS as an activation agent offers the following advantages:

    • You need not write a separate server program to register the remotable classes.

    • You need not worry about finding an available port for your server application. You can just host the remotable object and IIS automatically using the port 80.

    • IIS can provide other functionalities such as authentication and secure socket layers (SSL).

  10. A remotable object is capable of being called asynchronously by default; therefore, no extra efforts are required in order to create remote objects that can be called asynchronously.

Answers to Exam Questions

  1. A and B. Your objective is to provide access to only authorized clients. Authorization is a function of the remoting host. IIS is the only available remoting host that provides you with this capability. IIS only supports HTTP communication. Therefore, you can use either the HttpChannel or HttpServerChannel channel because both allow you to listen to incoming messages from clients. IIS does not support TcpChannel and TcpServerChannel; therefore, if you use these channels, you'll have to write additional code to implement security, and this is not desired in the given scenario.

  2. C. Firewalls generally allow HTTP messages to pass through, and the binary formatter provides a size-optimized format of encoding data. Using TCP might require administrators to open additional ports in the firewall, whereas the SOAP format is verbose when compared to TCP and would take bandwidth, which is not a desirable solution for clients using slow connections.

  3. A. Only server-activated objects in SingleCall activation mode support load-balancing because they do not maintain state across the method calls.

  4. B. You should store the remoting configuration in a web.config file. This file is an XML-based configuration file that is easy to modify and does not require a separate compilation step. Storing a configuration setting in gwpoinfo.dll or global.asax requires the additional step of compilation before the settings come into effect. The machine.config file is not suggested because any changes done to it will affect all the applications running on the server.

  5. B. When you want to create just one instance of a remote object irrespective of the number of clients, you must create a server-activated (WellKnown) object in the Singleton activation mode.

  6. B. IIS only supports WellKnown or server-activated objects. Therefore, you must use the <WellKnown> element instead of the <activated> element. Also, you are specifying the configuration for the server; therefore, you must use the <server> element instead of the <client> element inside the <application> element to configure the WellKnown object.

  7. D. Because you know that the server's .NET remoting application is using HTTP protocol, you can use the Soapsuds tool to automatically generate the metadata for the server.

  8. D. You should use IIS as the remoting host because IIS has built-in support for Integrated Windows authentication. You'll have to write additional code to achieve this with the other techniques.

  9. A. In a case in which you just have an interface to a class and not the original class, you cannot use the New operator to instantiate the remote object. You should instead use the static methods of the Activator class. The Activator.GetObject() method is used to instantiate a server-activated object, whereas Activator.CreateInstance() method is used to instantiate a client-activated object.

  10. C. Your requirement is to register a client-activated remote object; therefore, you'll use the RegisterActivatedServiceType() method. The RegisterActivatedClientType() method is used to register the CAO with the remoting system in the client's application domain. The other two options are for creating the server-activated objects.

  11. B. In the preceding program, although you have created an instance of TcpServerChannel and HttpServerChannel objects, you haven't yet registered them with the remoting framework. You'll register the channels using the RegisterChannel() method of the ChannelServices class.

  12. B and C. When creating a client channel, you should not specify a port number with the channel constructor. Instead, the port number should be used with the URL of the remote object.

  13. B and D. The soapsuds tool is capable of generating metadata for server-activated objects on the HTTP channel.

  14. D. The issue in the question is not of speed but of responsiveness. This behavior is because the Windows application is calling the methods on the remote object synchronously. You can make the user interface more responsive by simply calling the remote method asynchronously. No modifications are needed on the remotable object to achieve this behavior.

  15. B and C. Only non-static public methods, properties, and fields participate in remoting.

Suggested Readings and Resources

  1. Visual Studio .NET Combined Help Collection

    • .NET Remoting Overview

    • Remoting Examples

  2. Ingo Rammer. Advanced .NET Remoting. Apress, 2002.

  3. http://www.iana.org/assignments/port-numbers—List of assigned port numbers.

Pearson IT Certification Promotional Mailings & Special Offers

I would like to receive exclusive offers and hear about products from Pearson IT Certification and its family of brands. I can unsubscribe at any time.

Overview


Pearson Education, Inc., 221 River Street, Hoboken, New Jersey 07030, (Pearson) presents this site to provide information about Pearson IT Certification products and services that can be purchased through this site.

This privacy notice provides an overview of our commitment to privacy and describes how we collect, protect, use and share personal information collected through this site. Please note that other Pearson websites and online products and services have their own separate privacy policies.

Collection and Use of Information


To conduct business and deliver products and services, Pearson collects and uses personal information in several ways in connection with this site, including:

Questions and Inquiries

For inquiries and questions, we collect the inquiry or question, together with name, contact details (email address, phone number and mailing address) and any other additional information voluntarily submitted to us through a Contact Us form or an email. We use this information to address the inquiry and respond to the question.

Online Store

For orders and purchases placed through our online store on this site, we collect order details, name, institution name and address (if applicable), email address, phone number, shipping and billing addresses, credit/debit card information, shipping options and any instructions. We use this information to complete transactions, fulfill orders, communicate with individuals placing orders or visiting the online store, and for related purposes.

Surveys

Pearson may offer opportunities to provide feedback or participate in surveys, including surveys evaluating Pearson products, services or sites. Participation is voluntary. Pearson collects information requested in the survey questions and uses the information to evaluate, support, maintain and improve products, services or sites; develop new products and services; conduct educational research; and for other purposes specified in the survey.

Contests and Drawings

Occasionally, we may sponsor a contest or drawing. Participation is optional. Pearson collects name, contact information and other information specified on the entry form for the contest or drawing to conduct the contest or drawing. Pearson may collect additional personal information from the winners of a contest or drawing in order to award the prize and for tax reporting purposes, as required by law.

Newsletters

If you have elected to receive email newsletters or promotional mailings and special offers but want to unsubscribe, simply email information@informit.com.

Service Announcements

On rare occasions it is necessary to send out a strictly service related announcement. For instance, if our service is temporarily suspended for maintenance we might send users an email. Generally, users may not opt-out of these communications, though they can deactivate their account information. However, these communications are not promotional in nature.

Customer Service

We communicate with users on a regular basis to provide requested services and in regard to issues relating to their account we reply via email or phone in accordance with the users' wishes when a user submits their information through our Contact Us form.

Other Collection and Use of Information


Application and System Logs

Pearson automatically collects log data to help ensure the delivery, availability and security of this site. Log data may include technical information about how a user or visitor connected to this site, such as browser type, type of computer/device, operating system, internet service provider and IP address. We use this information for support purposes and to monitor the health of the site, identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents and appropriately scale computing resources.

Web Analytics

Pearson may use third party web trend analytical services, including Google Analytics, to collect visitor information, such as IP addresses, browser types, referring pages, pages visited and time spent on a particular site. While these analytical services collect and report information on an anonymous basis, they may use cookies to gather web trend information. The information gathered may enable Pearson (but not the third party web trend services) to link information with application and system log data. Pearson uses this information for system administration and to identify problems, improve service, detect unauthorized access and fraudulent activity, prevent and respond to security incidents, appropriately scale computing resources and otherwise support and deliver this site and its services.

Cookies and Related Technologies

This site uses cookies and similar technologies to personalize content, measure traffic patterns, control security, track use and access of information on this site, and provide interest-based messages and advertising. Users can manage and block the use of cookies through their browser. Disabling or blocking certain cookies may limit the functionality of this site.

Do Not Track

This site currently does not respond to Do Not Track signals.

Security


Pearson uses appropriate physical, administrative and technical security measures to protect personal information from unauthorized access, use and disclosure.

Children


This site is not directed to children under the age of 13.

Marketing


Pearson may send or direct marketing communications to users, provided that

  • Pearson will not use personal information collected or processed as a K-12 school service provider for the purpose of directed or targeted advertising.
  • Such marketing is consistent with applicable law and Pearson's legal obligations.
  • Pearson will not knowingly direct or send marketing communications to an individual who has expressed a preference not to receive marketing.
  • Where required by applicable law, express or implied consent to marketing exists and has not been withdrawn.

Pearson may provide personal information to a third party service provider on a restricted basis to provide marketing solely on behalf of Pearson or an affiliate or customer for whom Pearson is a service provider. Marketing preferences may be changed at any time.

Correcting/Updating Personal Information


If a user's personally identifiable information changes (such as your postal address or email address), we provide a way to correct or update that user's personal data provided to us. This can be done on the Account page. If a user no longer desires our service and desires to delete his or her account, please contact us at customer-service@informit.com and we will process the deletion of a user's account.

Choice/Opt-out


Users can always make an informed choice as to whether they should proceed with certain services offered by Adobe Press. If you choose to remove yourself from our mailing list(s) simply visit the following page and uncheck any communication you no longer want to receive: www.pearsonitcertification.com/u.aspx.

Sale of Personal Information


Pearson does not rent or sell personal information in exchange for any payment of money.

While Pearson does not sell personal information, as defined in Nevada law, Nevada residents may email a request for no sale of their personal information to NevadaDesignatedRequest@pearson.com.

Supplemental Privacy Statement for California Residents


California residents should read our Supplemental privacy statement for California residents in conjunction with this Privacy Notice. The Supplemental privacy statement for California residents explains Pearson's commitment to comply with California law and applies to personal information of California residents collected in connection with this site and the Services.

Sharing and Disclosure


Pearson may disclose personal information, as follows:

  • As required by law.
  • With the consent of the individual (or their parent, if the individual is a minor)
  • In response to a subpoena, court order or legal process, to the extent permitted or required by law
  • To protect the security and safety of individuals, data, assets and systems, consistent with applicable law
  • In connection the sale, joint venture or other transfer of some or all of its company or assets, subject to the provisions of this Privacy Notice
  • To investigate or address actual or suspected fraud or other illegal activities
  • To exercise its legal rights, including enforcement of the Terms of Use for this site or another contract
  • To affiliated Pearson companies and other companies and organizations who perform work for Pearson and are obligated to protect the privacy of personal information consistent with this Privacy Notice
  • To a school, organization, company or government agency, where Pearson collects or processes the personal information in a school setting or on behalf of such organization, company or government agency.

Links


This web site contains links to other sites. Please be aware that we are not responsible for the privacy practices of such other sites. We encourage our users to be aware when they leave our site and to read the privacy statements of each and every web site that collects Personal Information. This privacy statement applies solely to information collected by this web site.

Requests and Contact


Please contact us about this Privacy Notice or if you have any requests or questions relating to the privacy of your personal information.

Changes to this Privacy Notice


We may revise this Privacy Notice through an updated posting. We will identify the effective date of the revision in the posting. Often, updates are made to provide greater clarity or to comply with changes in regulatory requirements. If the updates involve material changes to the collection, protection, use or disclosure of Personal Information, Pearson will provide notice of the change through a conspicuous notice on this site or other appropriate way. Continued use of the site after the effective date of a posted revision evidences acceptance. Please contact us if you have questions or concerns about the Privacy Notice or any objection to any revisions.

Last Update: November 17, 2020