mercredi 24 juin 2015

Autofac couldn't resolve dependency on TeamCity

I have a such code (It's a part of unit tests executed by nunit-console):

class MyClass
{
    [DI(Type = typeof(MyClass))]
    public IMyClass MyClassProperty {get;set;}
}

By reflection i'm scanning such classes and then register in Autofac:

// Register MyClass as IMyClass
autofacBuilder.RegisterType(diAttribute.Type).As(propertyInfo.PropertyType);

After that i need to resolve this property in the same way - by reflection:

autofacContainer.Resolve(propertyInfo.PropertyType) // it contains IMyClass

When I'm launching this code locally it works well. But doesn't work on TeamCity. Fails with error:

Error: 'Autofac.Core.DependencyResolutionException: An exception was thrown while executing a resolve operation. See the InnerException for details. ---> Common Language Runtime detected an invalid program. (See inner exception for details.) ---> System.InvalidProgramException: Common Language Runtime detected an invalid program.





Aucun commentaire:

Enregistrer un commentaire