我使用VS 2017安装程序创建Winform应用程序的安装文件。当我在PC上测试此安装文件时,登录运行正常。因此,我在其他PC上运行此安装文件。
但是,当我确定数据库中的用户名和密码正确时,应用程序会说“对象引用未设置为对象的实例”。>
我见过What is a NullReferenceException, and how do I fix it?,但我不认为这是空异常,因为安装的应用程序在我的PC中没有引发以上错误。仅当我在其他PC上安装该应用程序时,才会发生此错误。
我还尝试用其他PC上相同应用程序的文件替换其他PC中已安装应用程序文件夹中的.exe和.config文件(效果很好),并且该应用程序可以正常运行。但是,然后我重新启动这些PC,并尝试登录该应用程序,同样的错误发生。
这是登录代码。我相信我已经正确检查了null异常。我说的对吗?
private void btnLogin_Click(object sender, EventArgs e)
{
try
{
var info = UsersBiz.Login(txtUserName.Text.Trim(), txtPassWord.Text);
if (info != null && info.user.Id > 0)
{
Constants.USERINFO = info;
this.Hide();
var frm = new frmMain();
frm.Show();
if (ckbRemember.Checked)
{
ManagementInventory.Properties.Settings.Default.User = txtUserName.Text;
ManagementInventory.Properties.Settings.Default.Pass = txtPassWord.Text;
ManagementInventory.Properties.Settings.Default.Save();
}
}
else
{
MessageBox.Show("UserName or Password not correct!");
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
我使用VS 2017安装程序创建Winform应用程序的安装文件。当我在PC上测试此安装文件时,登录运行正常。因此,我在其他PC上运行此安装文件。但是,当我在...
最简单的方法是在运行程序的计算机上使用Visual Studio调试器。如果该计算机上没有Visual Studio,请考虑使用删除调试。参见how to start debugging on a remote computer