使用NBear开发时,出现异常!

winsei 2009-04-29 04:24:36
“/”应用程序中的服务器错误。
--------------------------------------------------------------------------------

Generic parameter type - IServiceInterfaceType must be an interface implementing NBear.IoC.Service.IServiceInterface or marked with ServiceContractAttribute.
说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。

异常详细信息: System.ArgumentException: Generic parameter type - IServiceInterfaceType must be an interface implementing NBear.IoC.Service.IServiceInterface or marked with ServiceContractAttribute.

源错误:


行 23:
行 24: ServiceFactory factory = ServiceFactory.Create();
行 25: IProductService ips = factory.GetService<IProductService>();

在运行时出现这个异常,编译是成功的。我是按照NBear教程的IOC篇一步步做下来的,中间没有遗漏任何东西。上面异常的意思是我没有使用接口参数,但我分明传的是借口啊!!!
以下是NBear项目中,这个该方法的部分代码:
public IServiceInterfaceType GetService<IServiceInterfaceType>()
//where IServiceInterfaceType : IServiceInterface
{
Exception ex = new ArgumentException("Generic parameter type - IServiceInterfaceType must be an interface implementing NBear.IoC.Service.IServiceInterface or marked with ServiceContractAttribute.");
//如果非接口类型,则抛出异常
if (!typeof(IServiceInterfaceType).IsInterface)
{
throw ex;
}

求救!!!
...全文
64 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
winsei 2009-05-16
  • 打赏
  • 举报
回复
教程有误!IProductService 应继承IServiceInterface接口。
tddw 2009-05-12
  • 打赏
  • 举报
回复
应该是配置文件里的数据库信息或字段信息配置的不对,
这玩意没用过,我一般用自己开发的数据持久层。
wodexiaohao 2009-05-12
  • 打赏
  • 举报
回复
呵呵

看来teddy ma的Nbear很受欢迎啊

你问问teddy去吧,如果他有时间应该会帮你的
阿非 2009-05-12
  • 打赏
  • 举报
回复
IProductService
你是怎么定义的
winsei 2009-04-30
  • 打赏
  • 举报
回复
没人回答啊???
itcrazyman 2009-04-29
  • 打赏
  • 举报
回复
mark up 帮顶

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧