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...Compile a Client Against an Interface?

This example illustrates how to build a client that does not reference a server object at compile time. The following code example demonstrates the client code.


Imports System
Imports System.Runtime.Remoting
Imports System.Runtime.Remoting.Channels
Imports System.Runtime.Remoting.Channels.TCP

Namespace Microsoft.Samples.Remoting.RemotingSamples
    Public Class Client
        Shared Sub Main
            Dim chan As TCPChannel
            chan = New TCPChannel()
            ChannelServices.RegisterChannel(chan)
            Dim obj As IHello
            obj = CType(Activator.GetObject(Type.GetType("RemotingSamples.IHello,share"), "tcp://localhost:8085/SayHello"),IHello)
            If obj Is Nothing
                System.Console.WriteLine("Could not locate server")
            Else
	            Console.WriteLine(obj.HelloMethod("Caveman"))
            End If
        End Sub
    End Class
End Namespace
VB

The client calls GetObject on an endpoint without knowing what the exact object type is. All it knows is that the object implements IHello.

VB Interface
View Source

[This sample can be found at H:\Home\WU_000036_efe47225c86ca62f325a01d8519bc002\Webs\aspnet.sk\quickstarts\QuickStartv20\HowTo\Samples\Remoting\interface\
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.