对象引用未设置为实例对象 [英] object reference not set to an instance an object

查看:117
本文介绍了对象引用未设置为实例对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我有一个vb.net应用程序,它与excel文件进​​行交互并从中获取数据并将它们写入文本文件.当我运行项目代码时,它会成功运行,并将数据从excel中写入文本文件.

但是,当我直接运行EXE文件时,它显示了一个错误,对象引用未设置为实例对象".当我准备并运行项目的安装程序时,发生了相同的错误.

请任何人分享您的想法以解决此问题.

谢谢,
Sivakumar.M.

Hi,

I have an vb.net application which interacts with an excel file and gets the data from it and write them into an text file. When i run my project code, it is running successfully and writes the data into a text file from excel.

But when i run the EXE file directly, it is showing an error, "object reference not set to an instance an object". The same error occurred when i prepare and run the setup of the project.

Please can anyone share your ideas to troubleshoot this issue.

Thanks,
Sivakumar.M.

推荐答案

很可能,excel的文件路径可能不正确.
检查它是否正常工作.
Most probably, the file path to the excel may be incorrect.
Check if this is working correctly.


对象引用未设置为实例对象
可能在对象未初始化或具有空值时发生.

始终检查所有对象的内容
object reference not set to an instance an object
This Occurs probably when object is not initialized or Having null value.

Check this for all your objects in all the way
Which may Solve your Problem.


以进一步了解Abhinav的答案,也请检查

1. Excel已安装在计算机上并正确引用
2.您要从中提取数据的excel文件的路径已正确设置
to Further Abhinav''s answer also check

1. Excel is installed on the machine and referenced properly
2. the path to the excel file that you are extracting data from is correctly setup


这篇关于对象引用未设置为实例对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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