Open Closed

How to add a new Module to existing Solution #80

ricardo.carvalho created

Hi. I created a new solution for my Main project and now I'm trying to add a new Module to it. My solution uses Angular and I'm creating the new module with --no-ui so that I can then create the Angular modules separate.

I added the new module to a sub-folder of the solution and added Existing Project to the main solution like it was suggested in below.


Every module can be a separate solution (like we did for the modules) or you can develop it under a single Visual Studio solution (for example, in the microservice demo, we've included a product module into the solution).

I suggest you to go with a single solution at the beginning since it is easier to develop, test, run and maintain. You know, in a single solution, you can cross reference projects. Assuming you will create your module as layered (like this), your application's domain layer should depend on the module's domain layer and so on (as a good practice, but you don't have to do). Also, add standard DependsOn attribute (see the document) when you add a project reference.

You can create a new module (using abp new MyProductName.MyModuleName -t module-pro - see), then add its projects to the application's solution then add references and dependson attributes. In the future, we will also automate this.

For the UI part, you can investigate the Angular UI modules we've created to understand how a module is developed. We are using them as NPM packages in the main application, however it may not be practical in development. @mehmet can write you more about that.

My solution now has the following structure.

I then went to the main Gmcs.Themis.HttpApi.Host and added the depends on the new module

Everything compiles and Runs, and the new methods for the Module display in Swagger but when i try to execute it fails and the following error is added to the Log.

2020-03-30 15:30:44.137 +01:00 [INF] Request starting HTTP/1.1 GET https://localhost:44338/api/ScreenBuilder/sample
2020-03-30 15:30:44.142 +01:00 [INF] Identity.Application was not authenticated. Failure message: Unprotect ticket failed 2020-03-30 15:30:44.142 +01:00 [DBG] AuthenticationScheme: Bearer was not authenticated. 2020-03-30 15:30:44.144 +01:00 [INF] Identity.Application was not authenticated. Failure message: Unprotect ticket failed 2020-03-30 15:30:44.144 +01:00 [INF] Identity.Application was not authenticated. Failure message: Unprotect ticket failed 2020-03-30 15:30:44.148 +01:00 [INF] Executing endpoint 'Gmcs.Themis.ScreenBuilder.Samples.SampleController.GetAsync (Gmcs.Themis.ScreenBuilder.HttpApi)' 2020-03-30 15:30:44.150 +01:00 [INF] Route matched with {action = "Get", controller = "Sample", area = "", page = ""}. Executing controller action with signature System.Threading.Tasks.Task1[Gmcs.Themis.ScreenBuilder.Samples.SampleDto] GetAsync() on controller Gmcs.Themis.ScreenBuilder.Samples.SampleController (Gmcs.Themis.ScreenBuilder.HttpApi). 2020-03-30 15:30:44.153 +01:00 [ERR] ---------- RemoteServiceErrorInfo ---------- 2020-03-30 15:30:44.154 +01:00 [ERR] { "code": null, "message": "An internal error occurred during your request!", "details": null, "validationErrors": null } 2020-03-30 15:30:44.154 +01:00 [ERR] An exception was thrown while activating Castle.Proxies.SampleControllerProxy. Autofac.Core.DependencyResolutionException: An exception was thrown while activating Castle.Proxies.SampleControllerProxy. ---> Autofac.Core.DependencyResolutionException: None of the constructors found with 'Autofac.Core.Activators.Reflection.DefaultConstructorFinder' on type 'Castle.Proxies.SampleControllerProxy' can be invoked with the available services and parameters: Cannot resolve parameter 'Gmcs.Themis.ScreenBuilder.Samples.ISampleAppService sampleAppService' of constructor 'Void .ctor(Castle.DynamicProxy.IInterceptor[], Gmcs.Themis.ScreenBuilder.Samples.ISampleAppService)'. at Autofac.Core.Activators.Reflection.ReflectionActivator.GetValidConstructorBindings(IComponentContext context, IEnumerable1 parameters) at Autofac.Core.Activators.Reflection.ReflectionActivator.ActivateInstance(IComponentContext context, IEnumerable1 parameters) at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable1 parameters, Object& decoratorTarget) --- End of inner exception stack trace --- at Autofac.Core.Resolving.InstanceLookup.Activate(IEnumerable1 parameters, Object& decoratorTarget) at Autofac.Core.Resolving.InstanceLookup.Execute() at Autofac.Core.Resolving.ResolveOperation.GetOrCreateInstance(ISharingLifetimeScope currentOperationScope, IComponentRegistration registration, IEnumerable1 parameters) at Autofac.Core.Resolving.ResolveOperation.Execute(IComponentRegistration registration, IEnumerable1 parameters) at Autofac.ResolutionExtensions.TryResolveService(IComponentContext context, Service service, IEnumerable1 parameters, Object& instance) at Autofac.ResolutionExtensions.ResolveService(IComponentContext context, Service service, IEnumerable`1 parameters) at Microsoft.AspNetCore.Mvc.Controllers.ServiceBasedControllerActivator.Create(ControllerContext actionContext) at Microsoft.AspNetCore.Mvc.Controllers.ControllerFactoryProvider.<>c__DisplayClass5_0.<CreateControllerFactory>g__CreateController|0(ControllerContext controllerContext) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.Next(State& next, Scope& scope, Object& state, Boolean& isCompleted) at Microsoft.AspNetCore.Mvc.Infrastructure.ControllerActionInvoker.InvokeInnerFilterAsync() --- End of stack trace from previous location where exception was thrown --- at Microsoft.AspNetCore.Mvc.Infrastructure.ResourceInvoker.<InvokeNextExceptionFilterAsync>g__Awaited|25_0(ResourceInvoker invoker, Task lastTask, State next, Scope scope, Object state, Boolean isCompleted) 2020-03-30 15:30:44.154 +01:00 [ERR] ---------- Exception Data ---------- 2020-03-30 15:30:44.155 +01:00 [ERR] ActivatorChain = Castle.Proxies.SampleControllerProxy 2020-03-30 15:30:44.155 +01:00 [INF] Executing ObjectResult, writing value of type 'Volo.Abp.Http.RemoteServiceErrorResponse'. 2020-03-30 15:30:44.157 +01:00 [INF] Executed action Gmcs.Themis.ScreenBuilder.Samples.SampleController.GetAsync (Gmcs.Themis.ScreenBuilder.HttpApi) in 6.7848ms 2020-03-30 15:30:44.157 +01:00 [INF] Executed endpoint 'Gmcs.Themis.ScreenBuilder.Samples.SampleController.GetAsync (Gmcs.Themis.ScreenBuilder.HttpApi)' 2020-03-30 15:30:44.157 +01:00 [INF] Request finished in 20.4769ms 500 application/json; charset=utf-8

What an I missing?

Another option is, does anyone have a sample solution with more than one module being used using Angular?

1 Answer(s)
  • 0
    alper created
    Support Team

    The problem is dependency! Cannot resolve parameter 'Gmcs.Themis.ScreenBuilder.Samples.ISampleAppService' Check that SampleAppService is registered correctly.


    public interface ISampleAppService : IApplicationService


    public class SampleAppService  : ApplicationService, ISampleAppService