I have the following classes and I am trying to implement Dependency Injection into calling a WCF Service. IUserProxyService : IApplicationService
CreateUser(User user)
UserProxyService : IUserProxyService
private IUserRepository repository;
public UserProxyService()
{
}
public UserProxyService(IUserRepository _repository)
{
repository = _repository;
}
CreateUser()
{repository.CreateUser(User);}
IUserRepository
CreateUser()
UserRepository : IUserRepository
public UserRepository()
{
proxy = new WCFServiceClient();
}
//for mocking
public UserRepository(IWCFService_proxy)
{
proxy = _proxy;
}
CreateUser(User user)
{ proxy.CreateUser();}
Now, in UserAppService class in Authorisation.User(Application project). I am adding IUserProxyService as an additional parameter to my constructor. So that I can use that object to make createuser calls.
However, after doing this, when I load the Users section on the web application I am getting a javascript error:
_Header.js:74 Uncaught TypeError: Cannot read property 'app' of undefined at HTMLDocument.<anonymous> (_Header.js:74) at i (jquery.min.js:2) at Object.fireWith [as resolveWith] (jquery.min.js:2) at Function.ready (jquery.min.js:2) at HTMLDocument.K (jquery.min.js:2)
In Header.js: //Manage linked accounts var _userLinkService = abp.services.app.userLink; - erroring line
What am I doing wrong? Can you guide me in the right direction?
5 Answer(s)
-
0
Hi,
Can you check Logs.txt file for error details ? Probably an error ocurred while generating client side javascript code.
-
0
Yes, the error is abp.services.app cannot be loaded. However, I am not sure why does this happen only when I use IApplicationInterface
-
0
Can you show the error in Logs.txt?
-
0
DEBUG 2018-01-08 10:32:24,478 [6 ] Abp.Web.SignalR.Hubs.AbpCommonHub - A client is connected: {"ConnectionId":"ec33c09e-9270-4b28-bec3-e240676c583e","IpAddress":"::1","TenantId":2,"UserId":19,"ConnectTime":"2018-01-08T15:32:24.47856Z","Properties":{}} DEBUG 2018-01-08 10:32:24,681 [19 ] Abp.Web.SignalR.Hubs.AbpCommonHub - A client is registered: ec33c09e-9270-4b28-bec3-e240676c583e DEBUG 2018-01-08 10:32:46,821 [27 ] Abp.Web.SignalR.Hubs.AbpCommonHub - A client is disconnected: ec33c09e-9270-4b28-bec3-e240676c583e ERROR 2018-01-08 10:32:48,813 [21 ] nHandling.AbpApiExceptionFilterAttribute - Only one complex type allowed as argument to a web api controller action. But CreateUser contains more than one! Abp.AbpException: Only one complex type allowed as argument to a web api controller action. But CreateUser contains more than one! at Abp.WebApi.Controllers.Dynamic.Scripting.ActionScriptingHelper.GenerateBody(DynamicApiActionInfo actionInfo) at Abp.WebApi.Controllers.Dynamic.Scripting.jQuery.JQueryActionScriptGenerator.GenerateAjaxCallParameters() at Abp.WebApi.Controllers.Dynamic.Scripting.jQuery.JQueryActionScriptGenerator.GenerateMethod() at Abp.WebApi.Controllers.Dynamic.Scripting.jQuery.JQueryProxyGenerator.AppendMethod(StringBuilder script, DynamicApiControllerInfo controllerInfo, DynamicApiActionInfo methodInfo) at Abp.WebApi.Controllers.Dynamic.Scripting.jQuery.JQueryProxyGenerator.Generate() at Abp.WebApi.Controllers.Dynamic.Scripting.ScriptProxyManager.GetAllScript(ProxyScriptType type) at Abp.WebApi.Controllers.Dynamic.Scripting.AbpServiceProxiesController.GetAll(ProxyScriptType type) at lambda_method(Closure , Object , Object[] ) at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass10.<GetExecutor>b__9(Object instance, Object[] methodParameters) at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.Execute(Object instance, Object[] arguments) at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken) --- End of stack trace from previous location where exception was thrown --- at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task) at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task) at System.Web.Http.Controllers.ApiControllerActionInvoker.
-
0
Only one complex type allowed as argument to a web api controller action. But CreateUser contains more than one!
- It seems you're not providing your actual method signatures:
// UserProxyService : IUserProxyService CreateUser() { repository.CreateUser(User); } // IUserRepository CreateUser() // UserRepository : IUserRepository CreateUser(User user) { proxy.CreateUser(); }
- Do you really want UserProxyService to be an IApplicationService that can be directly called by a client?