Microsoft.Practices.Unity configuration issue - System.TypeInitializationException

865 views Asked by At

I have implement the Microsoft unity application block in one of my project.

Project's Unity configuration file is:

<UnityConfiguration xmlns="http://schemas.microsoft.com/practices/2010/unity">
<container>
  <register type="IInputAdapterPoc" mapTo="InputAdapterPoc" />
</container>
<alias alias="IInputAdapterPoc" type="Company.Product.Pocc.IInputAdapterPoc,Company.Product.Pocc" />
<alias alias="InputAdapterPoc" type="Company.Product.Pocc.InputAdapterPoc,Company.Product.Pocc" />

Project's Interface and concreate class:

namespace Company.Product.Pocc
{
    public class InputAdapterPoc : BaseInputAdapter, IInputAdapterPoc
    {
        public override void Process(Connector _connector) { }
        public override void Intialize(Entity _entity) { }
    }
}

namespace Company.Product.Pocc
{
    public interface IInputAdapterPoc : IInputAdapter { }
}

namespace Company.Product.Interface
{
    public interface IInputAdapter : IAdapter
    {
        void Process(Connector connect);
    }
}

namespace Company.Product.Adapter
{
    public abstract class BaseInputAdapter : IInputAdapter
    {
        public abstract void Process(Connector connect);
        public abstract void Intialize(Entity entityMapping);
    }
}

Problem is - while executing the code:

var instance = new UnityContainer().Resolve<AnyType>();

it throws the Exception:

Exception Type: System.TypeInitializationException

InnerException: {"The type name or alias IInputAdapterPoc could not be resolved. Please check your configuration file and verify this type name."}

Message:

The type initializer for 'Company.Product.Utility.UnityHelper' threw an exception.

How can I resolve this? Any idea?

0

There are 0 answers