我有以下类,并且我试图在ASP.NET零中实现对WCF的依赖注入。
接口IUserProxyService用CreateUser方法实现了IApplicationService。
类UserProxyService使用IUserRepository的构造注入实现IUserProxyService,并有一个CreateUser方法。
接口IUserRepository指定实现CreateUser方法。
类UserRespository使用公共构造函数实现IUserRepository,而不带parmaters调用WCF和另一个用于模拟的构造函数。该类包含对WCF服务的实际调用。
通过使用IApplicationService,根据文档,我的类由CastleWindsor在ASPNetZero中自动注册。现在,在UserAppService类中的Authorisation.User(应用程序项目)。我将添加IUserProxyService作为构造函数的附加参数。这样我就可以使用这个对象进行createuser调用。
但是,完成此操作后,当我在web应用程序上加载User部分时,我将得到一个javascript错误:
_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)在Header.js中:
//Manage linked accounts
var _userLinkService = abp.services.app.userLink; - erroring line我做错了什么?你能引导我朝正确的方向前进吗?回复
发布于 2018-07-17 10:54:29
我也有同样的问题。检查此项目,可能会更正此错误。
1- IApplicationService.必须实现AssetApplicationService
public interface IAssetApplicationService : IApplicationService
{
}
public class AssetApplicationService : IAssetApplicationService
{
}2-检查模块加载是否正确,并在其他模块中添加正确的依赖项。
using System.Reflection;
using System.Web.Http;
using Abp.Application.Services;
using Abp.Configuration.Startup;
using Abp.Modules;
using Abp.WebApi;
namespace YourApp.Api
{
[DependsOn(typeof(AbpWebApiModule),
typeof(YourAppCommonModule),
typeof(YourAppApplicationModule))]
public class YourAppWebApiModule : AbpModule
{
public override void Initialize()
{
IocManager.RegisterAssemblyByConvention(Assembly.GetExecutingAssembly());
Configuration.Modules.AbpWebApi().DynamicApiControllerBuilder
.ForAll<IApplicationService>(typeof(YourAppCommonModule).Assembly, "app")
.Build();
Configuration.Modules.AbpWebApi().DynamicApiControllerBuilder
.ForAll<IApplicationService>(typeof(YourAppApplicationModule).Assembly, "app")
.Build();
Configuration.Modules.AbpWebApi().HttpConfiguration.Filters.Add(new HostAuthenticationFilter("Bearer"));
}
}
}https://stackoverflow.com/questions/48157094
复制相似问题