Make Class1 public.
I have changed only that.
[ServiceContract]
interface Interface1
{
[OperationContract]
string getdata();
}
public class Class1 : Interface1
{
public string getdata()
{
return "wcf";
}
}
class Program
{
static void Main(string[] args)
{
ServiceHost obj = new ServiceHost(typeof(Class1));
obj.AddServiceEndpoint(typeof(Interface1), new BasicHttpBinding(), "http://localhost:7001/Class1");
obj.Open();
Console.WriteLine("start the service");
Console.ReadKey();
}
}
It worked fine without any error.