'System.ArgumentNullException' in WindsorContainer.Register(). Value cannot be null. Parameter name: name

406 Views Asked by At

I try to make work a code from aspnetboilerplate.

There is a call to WindsorContainer class function

public void Register(Type type, Type impl, DependencyLifeStyle lifeStyle = DependencyLifeStyle.Singleton)

which looks like this:

iocManager.Register(
                        typeof(IRepository<,>).MakeGenericType(entityType, primaryKeyType),
                        typeof(EfRepositoryBase<,,>).MakeGenericType(dbContextType, entityType, primaryKeyType),
                        DependencyLifeStyle.Transient
                        );

The resuting types are:

[System.RuntimeType] = {Name = "IRepository`2" FullName = "Abp.Domain.Repositories.IRepository`2"}

and

base = {Name = "EfRepositoryBase`3" FullName = null}

We can see that the instantiated by MakeGenericType() concrete type's FullName is null.

The class EfRepositoryBase3 looks like this:

 public class EfRepositoryBase<TDbContext, TEntity, TPrimaryKey> : IRepository<TEntity, TPrimaryKey>
        where TEntity : class, IEntity<TPrimaryKey>
        where TDbContext : DbContext
    {
         ... CRUD methods...
    }

Why the FullName of it is null and how the issue could be overcome?

1

There are 1 best solutions below

0
On

FullName can return null in some cases

The fully qualified name of the Type, including the namespace of the Type but not the assembly; or null if the current instance represents a generic type parameter, an array type, pointer type, or byref type based on a type parameter, or a generic type that is not a generic type definition but contains unresolved type parameters.

You can get a non null name by using the GetGenericTypeDefinition method.