文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>silverlight 反射调用WebService

silverlight 反射调用WebService

时间:2010-10-28  来源:吹风

        [WebMethod]
        public string HelloWorld()
        {
            return "您好!";
        }

silverlight中代码:

 

namespace DynamicDemo
{
    public partial class MainPage : UserControl
    {
        public MainPage()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, RoutedEventArgs e)
        {
            Type tp = Type.GetType("DynamicDemo.Server.RefServiceSoapClient");

            EventInfo Event = tp.GetEvent("HelloWorldCompleted");

            MethodInfo method = tp.GetMethod("HelloWorldAsync", new Type[] { }, new ParameterModifier[] { });
            
            var chuifeng = tp.Assembly.CreateInstance("DynamicDemo.Server.RefServiceSoapClient");

            Event.AddEventHandler(chuifeng, new EventHandler<DynamicDemo.Server.HelloWorldCompletedEventArgs>(aa_HelloWorldCompleted));

            method.Invoke(chuifeng, new object[] { });

        }

        void aa_HelloWorldCompleted(object sender, Server.HelloWorldCompletedEventArgs e)
        {
            MessageBox.Show("吹风说:" + e.Result);
        }
    }
}

 

 

 

 

 

相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载