Hi this is my wcf application
[ServiceContract]
public interface IService1
{
[OperationContract]
IEnumerable<Department> depts();
// TODO: Add your service operations here
}
//implementation
public class Service1 : IService1
{
public IEnumerable<Department> depts()
{
XDocument xdoc = XDocument.Load(HttpContext.Current.Server.MapPath("Dept.xml"));
IEnumerable<Department> depts = from p in xdoc.Descendants("Department")
select new Department
{
Name = p.Element("Id").Value,
Dept = p.Element("Dept").Value,
};
return depts;
}
}
//testing wcf in a web application
protected void Page_Load(object sender, EventArgs e)
{
ServiceReference1.Service1Client dd = new ServiceReference1.Service1Client();
GridView1.DataSource = dd.depts();
GridView1.DataBind();
}
this is the error
object reference not to set instance of an object