silverlight 访问web类
工程结构:

在ORA_JSON工程中点击属性更改一个设置

点击确定.
在ORA_JSON中建立CommonDao.cs
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ServiceModel.DomainServices.Server;
using System.ServiceModel.DomainServices.Hosting;
// [EnableClientAccess()] using System.ServiceModel.DomainServices.Server;
// [Invoke] using System.ServiceModel.DomainServices.Hosting;
// 放在类和方法前的标识会在编译所有类的时候进行特殊处理 不可缺少 否则在silverlight工程中将无法使用该类
namespace ORA_JSON.Web
{
[EnableClientAccess()]
public class CommonDao : DomainService
{
[Invoke]
public string GetInfo()
{
return "1";
}
}
}
然后点击顶部
图标你会在ORA_JSON.Web.g.cs文件中找到你的CommonDao类:

在MainPage.xaml.cs中调用new CommonDao().GetSignalInfo();

浙公网安备 33010602011771号