0

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?

Piuiui
  • 11
  • 4
  • I don't see any InputAdapterPocc (note "Pocc" instead of "Poc")) in your code, just fix your configuration file (2nd alias entry). – Adriano Repetti May 29 '15 at 07:52
  • ahhh. yes. its a typo!! copy paste typo :-) Modified the question body. – Piuiui May 29 '15 at 08:49
  • Please re-read exception message: _"The type name or alias **IInputAdapterPocc** could not be resolved. Please check your configuration file and verify this type name."_ That typo is also in your true configuration file, not just in your question body – Adriano Repetti May 29 '15 at 09:56
  • I suggest that you use unity fluent registration. It's much less error prone. – Ekk May 29 '15 at 10:22
  • ok Adriano!!! fixed it. :-| but not able to fix the problem :-( – Piuiui May 29 '15 at 12:16

0 Answers0