zoukankan      html  css  js  c++  java
  • MVC开发中的常见错误-04-“System.NullReferenceException”类型的异常在 BBFJ.OA.WebApp.dll 中发生,但未在用户代码中进行处理

    未将对象引用设置到对象实例,又名空指针异常,伴随程序员开发的一生.

    查看详细信息得知: SetUserRoleInfo()

    首先想到的是  IBLL.IRoleInfoService RoleInfoService { set; get; }应该是config文件中反射出现了问题

    <?xml version="1.0" encoding="utf-8" ?>
    <objects xmlns="http://www.springframework.net">
    
      <!--控制器-->
      <object type="BBFJ.OA.WebApp.Controllers.UserInfoController, BBFJ.OA.WebApp" singleton="false" >
        <!--控制器的属性-->
        <property name="UserInfoService" ref="userInfoService" />
      </object>
    
      <object type="BBFJ.OA.WebApp.Controllers.LoginController, BBFJ.OA.WebApp" singleton="false" >
        <!--控制器的属性-->
        <property name="UserInfoService" ref="userInfoService" />
      </object>
    
      <object type="BBFJ.OA.WebApp.Controllers.RoleInfoController, BBFJ.OA.WebApp" singleton="false" >
        <!--控制器的属性-->
        <property name="RoleInfoService" ref="roleInfoService" />
      </object>
      <!--intentionally do NOT register the AccountController or the ValuesController with the container; demonstrates that the underlying
      default controller factory will properly (attempt to!) resolve all controllers not registered with Spring.NET
      using its default controller resolution behavoir-->
      <!--<object type="Spring.Mvc4QuickStart.Controllers.AccountController, Spring.Mvc4QuickStart" singleton="false" />-->
      <!--<object type="Spring.Mvc4QuickStart.Controllers.ValuesController, Spring.Mvc4QuickStart" singleton="false" />-->
    </objects>
    
    
    
    
    
    
    <?xml version="1.0" encoding="utf-8" ?>
    <objects>
     
      <object type="BBFJ.OA.BLL.UserInfoService, BBFJ.OA.BLL" singleton="false" name="userInfoService">
        </object>
      <object type="BBFJ.OA.BLL.RoleInfoService, BBFJ.OA.BLL" singleton="false" name="roleInfoService">
      </object>
      
    </objects>
    View Code

    检查过后发现毛病

     <object type="BBFJ.OA.WebApp.Controllers.UserInfoController, BBFJ.OA.WebApp" singleton="false" >
        <!--控制器的属性-->
        <property name="UserInfoService" ref="userInfoService" />
        <property name="RoleInfoService" ref="roleInfoService" />
      </object>

  • 相关阅读:
    net core体系-2继续认识net core
    net core体系-1概要
    iOS开发UI篇—懒加载
    iOS开发UI篇—简单的浏览器查看程序
    iOS开发UI篇—transframe属性(形变)
    iOS开发UI基础—手写控件,frame,center和bounds属性
    iOS开发UI篇—Button基础
    Foundation框架—集合
    Foundation框架—字符串
    Foundation框架—结构体
  • 原文地址:https://www.cnblogs.com/YK2012/p/6656339.html
Copyright © 2011-2022 走看看