2014-11-08 3 views
1

aspnetboilerplate에서 작업 코드를 만들려고합니다. 다음과 같습니다 WindsorContainer 수준의 기능'System.ArgumentNullException'in WindsorContainer.Register(). 값은 null 일 수 없습니다. 매개 변수 이름 : 이름

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

에 대한 호출이 있습니다

:

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

resuting 유형은 다음과 같습니다

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

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

MakeGenericType() 구체 유형의 FullName으로 인스턴스화 된 것이 null임을 알 수 있습니다.

클래스 EfRepositoryBase3는 다음과 같습니다

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

왜 문제가 해결 될 수있는 그것의 FullNamenull 어떻게합니까?

답변

1

FullName 어떤 경우에는 null을 반환 할 수

유형의 네임 스페이스가 아닌 어셈블리를 포함하여 유형의 완전한 이름; 현재 인스턴스가 일반 형식 매개 변수, 배열 형식, 포인터 형식 또는 형식 매개 변수를 기반으로하는 byref 형식 을 나타내거나 일반 형식 형식이 아니지만 확인되지 않은 형식 매개 변수가 포함 된 제네릭 형식을 나타내는 경우 null입니다.

GetGenericTypeDefinition 메서드를 사용하면 null이 아닌 이름을 가져올 수 있습니다.

관련 문제