怎么了?你调用的对象是空的. [英] What's wrong? Object reference not set to an instance of an object.

查看:66
本文介绍了怎么了?你调用的对象是空的.的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我正在使用Visual Studio 2010,但不知道怎么了.我收到一条错误消息:对象引用未设置为对象的实例".

该错误不应该存在,因为我想我实例化了该对象.

请在下面检查我的代码:

Hi Guys,

I am using Visual Studio 2010 and I don''t know what''s wrong. I got an error that says - "Object reference not set to an instance of an object".

The error shouldn''t be there because I think I instantiated the object.

Please check my codes below:

Line:565   Dim Roles As New RolesFunctions

Line:566   If LCase(sLoginType) = LCase("admin") Then
Line:567      Call Roles.GetAdminRoles(nCompanyId, sStudentId)


...

错误指向第567行,说-对象引用未设置为对象的实例".

RolesFunctions是GetAdminRoles方法所在的公共类.

我会错过代码中的某些内容吗?

谢谢,

Hifiger


...

The error is pointing at line 567, says - "Object reference not set to an instance of an object".

The RolesFunctions is a Public Class where the GetAdminRoles method is located.

Do I missed something in the codes?

Thanks,

Hifiger

推荐答案

首先调试代码

检查行 566,567

将断点放在行号 566

确保在执行该行之前可以获取 sLoginType 的值.如果没有,您应该更改代码.

还要检查 sStudentId
Debug the code first

Check the Lines 566,567

Put the breakpoint in Line No 566

Make sure you can get the value for sLoginType before the line executed. If not you should change code.

Also check the value for sStudentId


这篇关于怎么了?你调用的对象是空的.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆