vendredi 14 octobre 2016

Unity resolver error using config

I am using Unity.MVC3 IOC container for DI. Trying to set up it using Unity configuration. With this configuration in place it is throwing " The type name or alias ExcelWriter could not be resolved. Please check your configuration file and verify this type name." error when it tries to resolves.

Interfaces are declared in a library: Framework
Namespace: Framework.Interfaces

namespace Framework.Interfaces
{
    public interface IExcelWriter
    {
        byte[] Write(DataTable dataTable);

        byte[] Write<T>(T data);
    }
}

Implemented classes are in separate library: ExcelUtility
Namespace: ExcelWorker

namespace ExcelWorker
{
    public class ExcelWriter : IExcelWriter
    {
        public byte[] Write(DataTable dt)
        {
            throw new NotImplementedException();
        }


        public byte[] Write<T>(T data)
        {
            throw new NotImplementedException();
        }
    }
}

And my configuration looks like :

<unity xmlns="http://ift.tt/1g8Zbje">
    <alias alias="IExcelWriter" type="Framework.Interfaces.IExcelWriter, Framework" ></alias>
    <assembly name="Framework" />
    <assembly name="ExcelUtility" />        
    <namespace name="ExcelUtility.ExcelWorker" ></namespace>
    <container>
      <register type="IExcelWriter" mapTo="ExcelWriter" />
    </container>
  </unity>

Aucun commentaire:

Enregistrer un commentaire