解决依赖性失败 - I / O异常

时间:2014-05-08 09:47:18

标签: c# exception object io unity-container

我从类DataProvider调用方法GetData,该方法作为接口实现。呼叫完成如下:

Response = ObjectRegistry.Instance.Resolve<IDataProvider>().GetData(id).

界面结构如下。

namespace A.B.C.D
{
  ///<Summary>
/// Gets the answer
///</Summary>
    public interface IDataProvider
    {

        GetDataInfo GetData(int id);
    }
}

我的DataProvider类看起来像。

namespace A.B.C.D
{
   public class DataProvider : IDataProvider
    {

       public GetDataInfo GetData(int id)
       {
           GetDataInfo DataInfo = new GetDataInfo();
           //return obj;

         return DataInfo;
      }
}
}

但是当我尝试执行此操作时,我遇到以下错误:

 Message: Resolution of the dependency failed, type = ".DataInfo.IDataProvider", name = "(none)".
Exception occurred while: while resolving.
Exception is: InvalidOperationException - The current type, DataInfo.IDataProvider, is an interface and cannot be constructed. Are you missing a type mapping?
-----------------------------------------------
At the time of the exception, the container was:

  Resolving DataInfo.IDataProvider,(none)

尝试搜索几乎所有SO帖子,但无法找到任何有用的建议

0 个答案:

没有答案