Base solution for your next web application
Starts in:
01 DAYS
01 HRS
01 MIN
01 SEC

Activities of "mightyit"

Hi

I am currently developing some Azure functions (.Net 2.2, V2) and it's support for dependency injection is highly unstable (almost non-existant, atm). In addition, AspNetZero / ABP conventions will not apply to Azure functions.

In this scenario, I am forced to new up instances of app services, and perhaps domain services.

I would specifically like to find out how I can new up instances of Crud App Services and generic repositories?

Thanks

I have downloaded a fresh Zero v6.7.0 base solution and am following the steps outlined in the getting started guide.

Once I have downloaded the project, ran yarn and npm run create-bundles, I update all my connectionstrings and run the migrator tool successfully, as can be seen from the below screenshot.

However, as soon as I run the *.Web.Mvc project, the following SqlException occurs:

System.Data.SqlClient.SqlException
  HResult=0x80131904
  Message=Invalid column name 'SubscriptionPaymentType'.
  Source=Core .Net SqlClient Data Provider
  StackTrace:
   at System.Data.SqlClient.SqlConnection.OnError(SqlException exception, Boolean breakConnection, Action`1 wrapCloseInAction)
   at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj, Boolean callerHasConnectionLock, Boolean asyncClose)
   at System.Data.SqlClient.TdsParser.TryRun(RunBehavior runBehavior, SqlCommand cmdHandler, SqlDataReader dataStream, BulkCopySimpleResultSet bulkCopyHandler, TdsParserStateObject stateObj, Boolean& dataReady)
   at System.Data.SqlClient.SqlDataReader.TryConsumeMetaData()
   at System.Data.SqlClient.SqlDataReader.get_MetaData()
   at System.Data.SqlClient.SqlCommand.FinishExecuteReader(SqlDataReader ds, RunBehavior runBehavior, String resetOptionsString)
   at System.Data.SqlClient.SqlCommand.RunExecuteReaderTds(CommandBehavior cmdBehavior, RunBehavior runBehavior, Boolean returnStream, Boolean async, Int32 timeout, Task& task, Boolean asyncWrite, SqlDataReader ds)
   at System.Data.SqlClient.SqlCommand.ExecuteReader(CommandBehavior behavior)
   at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.Execute(IRelationalConnection connection, DbCommandMethod executeMethod, IReadOnlyDictionary`2 parameterValues)
   at Microsoft.EntityFrameworkCore.Storage.Internal.RelationalCommand.ExecuteReader(IRelationalConnection connection, IReadOnlyDictionary`2 parameterValues)
   at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable`1.Enumerator.BufferlessMoveNext(DbContext _, Boolean buffer)
   at Microsoft.EntityFrameworkCore.SqlServer.Storage.Internal.SqlServerExecutionStrategy.Execute[TState,TResult](TState state, Func`3 operation, Func`3 verifySucceeded)
   at Microsoft.EntityFrameworkCore.Query.Internal.QueryingEnumerable`1.Enumerator.MoveNext()
   at System.Linq.Enumerable.TryGetFirst[TSource](IEnumerable`1 source, Boolean& found)
   at Microsoft.EntityFrameworkCore.Query.Internal.LinqOperatorProvider.ResultEnumerable`1.GetEnumerator()
   at Microsoft.EntityFrameworkCore.Query.Internal.LinqOperatorProvider.<_TrackEntities>d__17`2.MoveNext()
   at Microsoft.EntityFrameworkCore.Query.Internal.LinqOperatorProvider.ExceptionInterceptor`1.EnumeratorExceptionInterceptor.MoveNext()
   at System.Linq.Enumerable.TryGetFirst[TSource](IEnumerable`1 source, Boolean& found)
   at System.Linq.Enumerable.First[TSource](IEnumerable`1 source)
   at Microsoft.EntityFrameworkCore.Query.Internal.QueryCompiler.&lt;&gt;c__DisplayClass15_1`1.<CompileQueryCore>b__0(QueryContext qc)
   at System.Linq.Queryable.FirstOrDefault[TSource](IQueryable`1 source, Expression`1 predicate)
   at MyCompany.MySolution.Migrations.Seed.Tenants.DefaultTenantBuilder.CreateDefaultTenant() in D:\Projects\MySolution\src\MyCompany.MySolution.EntityFrameworkCore\Migrations\Seed\Tenants\DefaultTenantBuilder.cs:line 27
   at MyCompany.MySolution.Migrations.Seed.Tenants.DefaultTenantBuilder.Create() in D:\Projects\MySolution\src\MyCompany.MySolution.EntityFrameworkCore\Migrations\Seed\Tenants\DefaultTenantBuilder.cs:line 20
   at MyCompany.MySolution.Migrations.Seed.SeedHelper.SeedHostDb(MySolutionDbContext context) in D:\Projects\MySolution\src\MyCompany.MySolution.EntityFrameworkCore\Migrations\Seed\SeedHelper.cs:line 29
   at MyCompany.MySolution.Migrations.Seed.SeedHelper.WithDbContext[TDbContext](IIocResolver iocResolver, Action`1 contextAction) in D:\Projects\MySolution\src\MyCompany.MySolution.EntityFrameworkCore\Migrations\Seed\SeedHelper.cs:line 42
   at MyCompany.MySolution.Migrations.Seed.SeedHelper.SeedHostDb(IIocResolver iocResolver) in D:\Projects\MySolution\src\MyCompany.MySolution.EntityFrameworkCore\Migrations\Seed\SeedHelper.cs:line 18
   at MyCompany.MySolution.EntityFrameworkCore.MySolutionEntityFrameworkCoreModule.PostInitialize() in D:\Projects\MySolution\src\MyCompany.MySolution.EntityFrameworkCore\EntityFrameworkCore\MySolutionEntityFrameworkCoreModule.cs:line 61
   at System.Collections.Generic.List`1.ForEach(Action`1 action)
   at Abp.AbpBootstrapper.Initialize()

Please advise...

I have followed theGetting started guide to ensure that I install the following:

  • nodejs (v10.15.3) + npm (v6.4.1)
  • gulp - ensured I installed it globally (cli version 2.0.1 local version 3.9.1)
  • yarn (v1.13.0)
  • bundler & minifier Visual Studio extension (latest)

I then ran Yarn (twice - the first time around I received an error message), as per the guide, with the following results

Trying to run npm run create-bundles gives me the following error message

As per the following screenshots, it seems that none of my minified javascript files are generated:

Hi

I have created a solution which contains:

  • My generated base solution
  • Custom modules, on which the base solution is dependent.

My solution is organised in the following fashion:

  • Solution
    • Modules
      • MyCustomModule
        • MyCustomModule.Core.csproj
        • MyCustomModule.Core.Shared.csproj
        • MyCustomModule.EfCore.csproj
        • MyCustomModule.Application.csproj
        • MyCustomModule.Application.Shared.csproj
        • MyCustomModule.Web.csproj
          • Areas
            • App
              • Features
                • Feature K
                • Feature L
    • src (Generated base solution)
      • MyCompany.SystemName.Core.csproj
      • MyCompany.SystemName.Core.Shared.csproj
      • MyCompany.SystemName.EntityFrameworkCore.csproj
      • MyCompany.SystemName.Application.csproj
      • MyCompany.SystemName.Application.Shared.csproj
      • MyCompany.SystemName.Web.Core.csproj
      • MyCompany.SystemName.Web.Host.csproj
      • MyCompany.SystemName.Web.Mvc.csproj
        • Areas
          • App
            • Features
              • Feature X
              • Feature Y
        • Features
          • Feature A
          • Feature B
        • Some more stuff...

In our Mvc project we use Feature folders to organise our code, so that controllers, views and other portions of code that relates to a specific function is grouped together in one place.

The Razor view engine needs to know where to look for views, and as such I have reconfigured ViewLocationFormats and AreaViewLocationFormats as follows in Startup.cs of the MyCompany.SystemName.Web.Mvc.csproj project.

This has been done as follows:

public IServiceProvider ConfigureServices(IServiceCollection services)
{
    //MVC
    services.AddMvc(options =>
    {
        options.Filters.Add(new AutoValidateAntiforgeryTokenAttribute());
        options.Filters.Add<GlobalExceptionFilter>();
    })
    .SetCompatibilityVersion(CompatibilityVersion.Version_2_1)
    .AddRazorOptions(options =>
    {
        // {0} - Action Name
        // {1} - Controller Name
        // {2} - Area Name
        // Replace normal view entirely
        options.ViewLocationFormats.Clear();
        options.ViewLocationFormats.Add("/Features/{1}/{0}.cshtml"); 
        options.ViewLocationFormats.Add("/Features/{1}/Views/{0}.cshtml"); 
        options.ViewLocationFormats.Add("/Features/Shared/{0}.cshtml"); 
        options.ViewLocationFormats.Add("/Features/Shared/Views/{0}.cshtml"); 
        options.AreaViewLocationFormats.Clear();
        options.AreaViewLocationFormats.Add("/Areas/{2}/Features/{1}/{0}.cshtml"); 
        options.AreaViewLocationFormats.Add("/Areas/{2}/Features/{1}/Views/{0}.cshtml");
        options.AreaViewLocationFormats.Add("/Areas/{2}/Features/Shared/{0}.cshtml"); 
    });
...

This schema works correctly for views in MyCompany.SystemName.Web.Mvc.csproj. However, views contained in MyCustomModule.Web.csproj does not resolve correctly and I get the following internal server error:

Please advise....

Hi

I've been developing a module (let's call this "FooModule") to integrate with my base solution (let's call this "BaseModule").

I am currently trying to figure out how to invoke ModuleFoo entity migrations from ModuleBase (my base solution) when a new Tenant is created.

I noticed that, in my generated base solution BaseModule, the generated TenantManager class invokes the DbMigrator class of the base solution to trigger database creation and migration for the tenant, whenever a new tenant is created. This functionality is located in BaseModule's core/domain layer project.

I also studied the example blog module solution to see how module migrations should be handled. I noticed a TenantManager class has been created inside the module's core/domain layer project. The example application that consumes the module, though, is a simple console application without any entities of it's own. As such it does not properly demonstrate how a module with entity migrations would be properly integrated into a base solution, with DDD-type layering, that has migrations of its own.

I am thus tryng to figure out:

  1. Is there a convention or structure at play here where each module should have it's own tenantManager class?
  2. If not, this would mean that I would have to call code from my Module's domain layer from the domain layer of my base solution to perform this function? This would create a circular dependency, since my module relies on multitenancy and identity interfaces in my base solution.

Please help.  I'm getting the following error on PostInitialize of my WebMVC module application. Please advise - I have reviewed module dependencies and I am not sure what the DI system is looking for here / what convention I have broken:

Castle.MicroKernel.Handlers.HandlerException HResult=0x80131500 Message=Can't create component 'Abp.MultiTenancy.AbpTenantManager'2[[MyCompany.MySystem.MultiTenancy.Tenant, MyCompany.MySystem.Core, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null],[MyCompany.MySystem.Authorization.Users.User, MyCompany.MySystem.Core, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]]_9d905d3e-a891-4b74-a909-026b8044ccf5' **as it has dependencies to be satisfied.

'Abp.MultiTenancy.AbpTenantManager**'2[[MyCompany.MySystem.MultiTenancy.Tenant, MyCompany.MySystem.Core, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null],[MyCompany.MySystem.Authorization.Users.User, MyCompany.MySystem.Core, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null]]_9d905d3e-a891-4b74-a909-026b8044ccf5' is waiting for the following dependencies:

  • Service 'Abp.MultiTenancy.IAbpZeroDbMigrator' which was not registered. Source=Castle.Windsor StackTrace: at Castle.MicroKernel.Handlers.DefaultHandler.AssertNotWaitingForDependency() at Castle.MicroKernel.Handlers.DefaultHandler.ResolveCore(CreationContext context, Boolean requiresDecommission, Boolean instanceRequired, Burden& burden) at Castle.MicroKernel.Handlers.DefaultHandler.Resolve(CreationContext context, Boolean instanceRequired) at Castle.MicroKernel.DefaultKernel.ResolveComponent(IHandler handler, Type service, IDictionary additionalArguments, IReleasePolicy policy, Boolean ignoreParentContext) at Castle.MicroKernel.DefaultKernel.Castle.MicroKernel.IKernelInternal.Resolve(Type service, IDictionary arguments, IReleasePolicy policy, Boolean ignoreParentContext) at Castle.MicroKernel.DefaultKernel.Resolve(Type service, IDictionary arguments) at Castle.Windsor.MsDependencyInjection.ScopedWindsorServiceProvider.GetServiceInternal(Type serviceType, Boolean isOptional) at Castle.MicroKernel.ComponentActivator.FactoryMethodActivator1.Instantiate(CreationContext context) at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.InternalCreate(CreationContext context) at Castle.MicroKernel.ComponentActivator.AbstractComponentActivator.Create(CreationContext context, Burden burden) at Castle.MicroKernel.Lifestyle.AbstractLifestyleManager.CreateInstance(CreationContext context, Boolean trackedExternally) at Castle.Windsor.MsDependencyInjection.MsScopedLifestyleManager.Resolve(CreationContext context, IReleasePolicy releasePolicy) at Castle.MicroKernel.Handlers.DefaultHandler.ResolveCore(CreationContext context, Boolean requiresDecommission, Boolean instanceRequired, Burden& burden) at Castle.MicroKernel.Handlers.DefaultHandler.Resolve(CreationContext context, Boolean instanceRequired) at Castle.MicroKernel.Resolvers.DefaultDependencyResolver.Resolve(CreationContext context, ISubDependencyResolver contextHandlerResolver, ComponentModel model, DependencyModel dependency) at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.CreateConstructorArguments(ConstructorCandidate constructor, CreationContext context) at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.Instantiate(CreationContext context) at Castle.MicroKernel.ComponentActivator.DefaultComponentActivator.InternalCreate(CreationContext context) at Castle.MicroKernel.ComponentActivator.AbstractComponentActivator.Create(CreationContext context, Burden burden) at Castle.MicroKernel.Lifestyle.AbstractLifestyleManager.CreateInstance(CreationContext context, Boolean trackedExternally) at Castle.MicroKernel.Lifestyle.SingletonLifestyleManager.Resolve(CreationContext context, IReleasePolicy releasePolicy) at Castle.MicroKernel.Handlers.DefaultHandler.ResolveCore(CreationContext context, Boolean requiresDecommission, Boolean instanceRequired, Burden& burden) at Castle.MicroKernel.Handlers.DefaultHandler.Resolve(CreationContext context, Boolean instanceRequired) at Castle.MicroKernel.DefaultKernel.ResolveComponent(IHandler handler, Type service, IDictionary additionalArguments, IReleasePolicy policy, Boolean ignoreParentContext) at Castle.MicroKernel.DefaultKernel.Castle.MicroKernel.IKernelInternal.Resolve(Type service, IDictionary arguments, IReleasePolicy policy, Boolean ignoreParentContext) at Castle.MicroKernel.DefaultKernel.Resolve(Type service, IDictionary arguments) at Castle.Windsor.WindsorContainer.Resolve[T]() at MyCompany.MySystem.Web.Startup.MySystemWebMvcModule.PostInitialize() in D:\Projects\MySystem\src\MyCompany.MySystem.Web.Mvc\Startup\MySystemWebMvcModule.cs:line 69 at System.Collections.Generic.List1.ForEach(Action`1 action) at Abp.AbpBootstrapper.Initialize()

I am trying to understand the reasoning behind the module system, and under which circumstances it would be beneficial to implement it over other standard options such as class libraries and Nuget packages (that is not clear from the official documentation).

Specifically when contrasted to class libraries and Nuget packages, I am trying to understand it's distinct value proposition.

  1. Which distinct benefits do I gain when I create and implement an ABP module, as opposed to a class library or Nuget package?
  2. Under which circumstances would it beneficial to create an ABP module as opposed to a normal class library or Nuget package

In other words, why use the module system, rather than just creating a Nuget package?

Showing 11 to 17 of 17 entries