2

OK, 나는 지난 이틀 동안이 오류를 사냥 한 후 내 순발력 끝에 해요 : Ninject에 WCF 오류

Error activating IUserIssueRepository 
No matching bindings are available, and the type is not self-bindable. 
Activation path: 
2) Injection of dependency IUserIssueRepository into parameter userIssueRepository of constructor of type IssueTrackerService 
1) Request for IssueTrackerService 

Suggestions: 
1) Ensure that you have defined a binding for IUserIssueRepository. 
2) If the binding was defined in a module, ensure that the module has been loaded into the kernel. 
3) Ensure you have not accidentally created more than one kernel. 
4) If you are using constructor arguments, ensure that the parameter name matches the constructors parameter name. 
5) If you are using automatic module loading, ensure the search path and filters are correct. 

나는 나의 설정이 올바른지 (그대로 바인딩 등) 알고있다. 다음은 관련 wcf 서비스 관련 내용입니다. 물론 어셈블리 참조는 그대로 유지됩니다.

Global.asax.cs using Ninject; using Ninject.Extensions.Wcf;

namespace NextGenIT.Web.Wcf 
{ 
    public class Global : NinjectWcfApplication 
    { 
     protected override IKernel CreateKernel() 
     { 
      return new StandardKernel(new ServiceModule()); 
     } 
    } 
} 

ServiceModule.cs

using Ninject.Modules; 
using NextGenIT.Core.Domain; 

namespace NextGenIT.Web.Wcf 
{ 
    public class ServiceModule : NinjectModule 
    { 
     public override void Load() 
     { 
      this.Bind<IUserIssueRepository>() 
       .To<SqlUserIssueRepository>(); 
     } 
    } 
} 

IssueTrackerService.svc

<%@ 
ServiceHost 
Factory="Ninject.Extensions.Wcf.NinjectServiceHostFactory" 
Service="NextGenIT.Core.Services.IssueTrackerService" 
%> 

편집 1 : 전체 스택 추적 :

[FaultException`1: Error activating IUserIssueRepository 
No matching bindings are available, and the type is not self-bindable. 
Activation path: 
    2) Injection of dependency IUserIssueRepository into parameter userIssueRepository of constructor of type IssueTrackerService 
    1) Request for IssueTrackerService 

Suggestions: 
    1) Ensure that you have defined a binding for IUserIssueRepository. 
    2) If the binding was defined in a module, ensure that the module has been loaded into the kernel. 
    3) Ensure you have not accidentally created more than one kernel. 
    4) If you are using constructor arguments, ensure that the parameter name matches the constructors parameter name. 
    5) If you are using automatic module loading, ensure the search path and filters are correct. 
] 
    System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) +4729827 
    System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) +1725 
    NextGenIT.Services.Contracts.IIssueTrackerService.GetUserIssues(String userId) +0 
    NextGenIT.Services.Client.IssueTrackerClient.GetUserIssues(String userId) in D:\Projects\TFS\NextGenIssueTracker\branches\2011Updates\NextGenIT.Services.Client\Proxies\IssueTrackerClient.cs:46 
    NextGenIT.Tests.Integration.WebClient._default.Page_Load(Object sender, EventArgs e) in D:\Projects\TFS\NextGenIssueTracker\branches\2011Updates\NextGenIT.Tests.Integration.WebClient\default.aspx.cs:26 
    System.Web.Util.CalliHelper.EventArgFunctionCaller(IntPtr fp, Object o, Object t, EventArgs e) +25 
    System.Web.UI.Control.LoadRecursive() +71 
    System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +3064 
,

편집 2 : 인터페이스 및 구현

IUserIssueRepository.cs

using System.Collections.Generic; 
using NextGenIT.Services.Contracts; 

namespace NextGenIT.Core.Domain 
{ 
    public interface IUserIssueRepository 
    { 
     string CreateUser(IUser user); 
     int CreateIssue(IIssue issue); 
     int CreateComment(IComment comment); 
     IUser GetUser(string userId); 
     IIssue GetIssue(int issueId); 
     IEnumerable<IIssue> GetIssues(string userId); 
     IEnumerable<IComment> GetComments(string userId, int issueId); 
    } 
} 

SqlUserIssueRepository.cs 이것은 IUserIssueRepository을 구현하지 SqlUserIssueRepository으로 인해 발생할 수

using System.Collections.Generic; 
using NextGenIT.Services.Contracts; 

namespace NextGenIT.Core.Domain 
{ 
    public class SqlUserIssueRepository : IUserIssueRepository 
    { 
     public string CreateUser(IUser user) { return "1234"; } 
     public int CreateIssue(IIssue issue) { return 1; } 
     public int CreateComment(IComment comment) { return 1; } 
     public IUser GetUser(string userId) { return null; } 
     public IIssue GetIssue(int issueId) { return null; } 
     public IEnumerable<IIssue> GetIssues(string userId) { return null; } 
     public IEnumerable<IComment> GetComments(string userId, int issueId) { return null; } 
    } 
} 
+1

2 가지 : 1) 'Load'를 삽입하면 화재가 발생합니까? 2) 전체 스택 추적을 볼 수 있습니까? –

+0

Errr, 실제로 * 부름을 받았는지 확실하지 않습니다 ... 그렇지 않은 경우 원인은 무엇입니까? – Didaxis

답변

1

업데이트 : WCF 서비스를 호스팅하는 프로젝트의 이름을 변경했던 일부 지점에서

. 나는 global.asax의 마크 업을 점검 할 생각이 전혀 없었다.

실제로는 더 이상 존재하지 않는 파일에서 상속되었습니다. 프로젝트는 아무런 문제도 발생하지 않았고, 그 이유를 결코 생각할 수 없었습니다!

0

.

Ninject가 클래스를 인터페이스에 바인딩하려고합니다.

+0

아니요, IUserIssueRepository를 확실히 구현합니다 – Didaxis

+0

인터페이스를 게시 할 수 있습니까? –