I have two projects in the solution WCF and MVC. In the MVC project I use Ninject.Extensions.Wcf.Client . In both projects I use the interface Shop.Services.Abstract.IUserService

 [ServiceContract(Name = "IUserService")] public interface IUserService { [OperationContract] UserBM Create(UserBM user, string password); [OperationContract] void Update(UserBM user, string pass = null, bool changePassword = false); [OperationContract] UserBM GetById(Guid id); [OperationContract] void Delete(UserBM user); [OperationContract] UserBM LogOn(string eMail, string pass); [OperationContract] List<UserBM> GetAllUsers(); } 

When I create a 'service reference' in the MVC project, the service creates its own namespace Shop.Web.UserSeviceClient.IUserService, it turns out that my interfaces differ only in the namespace,

 [System.Diagnostics.DebuggerStepThroughAttribute()] [System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")] public partial class UserServiceClient : System.ServiceModel.ClientBase<Shop.Web.UserSeviceClient.IUserService>, Shop.Web.UserSeviceClient.IUserService { public UserServiceClient() { } public UserServiceClient(string endpointConfigurationName) : base(endpointConfigurationName) { } public UserServiceClient(string endpointConfigurationName, string remoteAddress) : base(endpointConfigurationName, remoteAddress) { } } 

in order to use Ninject it is necessary that the interfaces are the same, therefore I cannot bind UserServiceClient ( Shop.Web.UserSeviceClient.IUserService ) to the Shop.Services.Abstract.IUserService interface

 private void AddBindings() { ninjectKernel.Bind<IUserService>().ToServiceChannel("BasicHttpBinding_IUserService"); } 

Can anyone come across such a problem? help if not hard)

  • Why can not you? Bind as much as you want. Another thing is that you in the mvc project should use what the studio generated for you, and not use the interface directly from the wcf-project. - Veikedo

1 answer 1

It is not necessary to add a Service Reference to use the service - there are other ways. Moreover, Ninject.Extensions.Wcf.Client these very “other methods” - that is, you don't need the UserServiceClient class UserServiceClient all!

Remove the Service Reference from the project, but leave the bindings in the web.config file - they will be useful.