WCF Runtime Error while using Constructor

Posted by Pranesh Nair on Stack Overflow See other posts from Stack Overflow or by Pranesh Nair
Published on 2011-01-07T04:22:54Z Indexed on 2011/01/07 4:54 UTC
Read the original article Hit count: 307

Filed under:
|

Hi all, I am new to WCF i am using constructor in my WCF service.svc.cs file....It throws this error when i use the constructor

The service type provided could not be loaded as a service because it does not have a default (parameter-less) constructor. To fix the problem, add a default constructor to the type, or pass an instance of the type to the host.

When i remove the constructor its working fine....But its compulsory that i have to use constructor...

This is my code

namespace UserAuthentication {

[ServiceBehavior(InstanceContextMode=System.ServiceModel.InstanceContextMode.Single)]
public class UserAuthentication : UserRepository,IUserAuthentication
{
    private ISqlMapper _mapper;
    private IRoleRepository _roleRepository;
    public UserAuthentication(ISqlMapper mapper): base(mapper)
    {
        _mapper = mapper;
        _roleRepository = new RoleRepository(_mapper);
    }


    public string EduvisionLogin(EduvisionUser aUser, int SchoolID)
    {
        UserRepository sampleCode= new UserRepository(_mapper);
        sampleCode.Login(aUser);
        return "Login Success";
    }
}

}

can anyone provide ideas or suggestions or sample code hw to resolve this issue...

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about wcf