I have created one basic WCF Service. It thrown an exception at line shown below.
ServiceHost host = new ServiceHost(typeof(MyApplication.ITransactionService1));
An unhandled exception of type 'System.ArgumentException' occurred in System.ServiceModel.dll Additional information: ServiceHost only supports class service types.
The ServiceHost Constructor (Type, Uri[]) expects a concrete type, not an interface.
Assuming that ITransactionService1
is your service contract and that you've implemented it in TransactionService1
:
namespace MyApplication
{
[ServiceContract]
public interface ITransactionService1
{
[OperationContract]
int DoSomething(string arg);
}
public class TransactionService1 : ITransactionService1
{
// Implementation logic
}
}
You would than pass MyApplication.TransactionService1
:
ServiceHost host = new ServieHost(typeof(MyApplication.TransactionService1));