AspNet.sk     Diskusné fóra     Vitajte v QuickStarts     ASP.NET     Silverlight     Ako môžem...? (en)     Class prehliadač Príklady chcem v ...   
Menu
Skip Navigation Links.

How Do I...? Common Tasks QuickStart Tutorial

How Do I...Pass An Object to a Server By Value?

The Pass an Object to a Server by Reference section illustrated that local objects are always passed by value when you call a remote function. To demonstrate this concept, you need change the previous example.

The first step is to create the object you need to pass to the server.


Imports System
Namespace Microsoft.Samples.Remoting.RemotingSamples

     Public Class ForwardMe
        Dim mValue As Integer = 1

        Public Sub CallMe()
            mValue += 1
        End Sub

        Public Function getValue() As Integer
            Return mValue
        End Function
    End Class
End Namespace

VB

This class is flagged with the [serializable] custom attribute, which allows it to be streamed to and from the server. When you run the sample, the client reports the value of the counter to be one. Since the server calls the CallMe method on the object five times, the value of the counter when the object is returned is six. Note that the client has two instances of the ForwardMe class after calling the remote method: the instance that was passed and a copy of the instance that was returned.

VB Passing by Value
View Source

[This sample can be found at H:\Home\WU_000036_efe47225c86ca62f325a01d8519bc002\Webs\aspnet.sk\quickstarts\QuickStartv20\HowTo\Samples\Remoting\byvalue\
To build this sample, open the SDK command prompt and navigate to the above path. Build the sample using the build tool msbuild passing the solution file as the first parameter: msbuild mySample.sln. The compiled executable will be found in the sub directory \bin directory.]




Microsoft .NET Framework SDK QuickStart Tutorials Version 2.0
Copyright � 2005 Microsoft Corporation. All rights reserved.


Microsoft .NET Framework SDK QuickStart Tutorials Version 2.0
Copyright © 2005 Microsoft Corporation. All rights reserved.
Preklad do slovenského jazyka - Copyright © 2005 - 2007 www.aspnet.sk, www.qsh.sk
Pošlite komentár k tejto stránke
Copyright © 2002 - 2008 Chastia, spol. s r. o., Igor Stanek, Designed by Lacino
Portál je hostovaný na serveroch firmy Quantasoft - www.qsh.sk.