WEB开发网
开发学院WEB开发ASP.NET 稳扎稳打Silverlight(53) - 4.0通信之对WCF NetTc... 阅读

稳扎稳打Silverlight(53) - 4.0通信之对WCF NetTcpBinding的支持

 2010-10-12 12:30:06 来源:WEB开发网   
核心提示: Form1.cs代码// 启动 WCF 服务,用于演示 Silverlight 4.0 与 WCF 的交互(基于 NetTcpBinding 绑定)private void LaunchNetTcpBinding(){ ServiceHost host = new ServiceHost(typ

Form1.cs

代码

// 启动 WCF 服务,用于演示 Silverlight 4.0 与 WCF 的交互(基于 NetTcpBinding 绑定)
private void LaunchNetTcpBinding()
{
    ServiceHost host = new ServiceHost(typeof(SocketServer.Duplex));
    host.Open();

    ShowMessage("演示 NetTcpBinding 的 WCF 服务已启动");
}

客户端(需要引用服务的元数据):

NetTcpBinding.xaml

代码

<navigation:Page x:Class="Silverlight40.Communication.NetTcpBinding"
           xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
           xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
           xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
           xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
           xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation"
           Title="NetTcpBinding Page">
    <Grid x:Name="LayoutRoot">
        <StackPanel HorizontalAlignment="Left">

            <Button Name="btnSend" Content="发送信息到服务端" Click="btnSend_Click" />
           
            <TextBlock Name="lblMsg" />
           
        </StackPanel>
    </Grid>
</navigation:Page>

上一页  1 2 3 4 5 6 7  下一页

Tags:稳扎稳打 Silverlight 通信

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接