以编程方式登录的问题

编程入门 行业动态 更新时间:2024-10-10 13:18:34
本文介绍了以编程方式登录的问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

嗨 我想以编程方式登录我的资源,我使用了这段代码,但是我处理了这个错误 对象引用未设置为对象的实例" 这是我的密码

Hi I want to login to my resorces programmatically, I used this code but I deal with this error "Object reference not set to an instance of an object" This is my codes

Public Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click STAOparation() End Sub Public Sub STAOparation() Dim WB As System.Windows.Forms.WebBrowser WB.Navigate("My_URL_LoginPage") Dim usernameTextBox As System.Windows.Forms.HtmlElement = WB.Document.All.Item(txtClientUsername) usernameTextBox.InnerText ="MY_UserName" Dim passwordTextBox As System.Windows.Forms.HtmlElement = WB.Document.All.Item(txtClientPassword) passwordTextBox.InnerText = "My_Pass"; WB.Document.GetElementById(cmdClientLogin).InvokeMember(click) End Sub

特定错误发生在WB.Navigate("My_URL_LoginPage")行上,我不知道如何解决 [/Edit]

the specefic error occured on WB.Navigate("My_URL_LoginPage") line and i dont know how do solve it [/Edit]

推荐答案

我看到您尚未创建Web浏览器控件的实例.您仅声明了变量WB,因此将其初始化为null.修复该错误,该错误将消失. 此致 Manfred I see you haven''t created an instance of the web browser control. You only declared the variable WB and it is thus initialized to null. Fix that and that error will be gone. Regards, Manfred

当您尝试使用空对象的属性时,会发生此错误. 更多详细信息:此处 [ ^ ] 简单地使用Visual Studio DEBUGGER可以告诉您该对象正在发生的原因.只需查看堆栈跟踪,然后在该行上放置调试器即可.检查该行的对象,看看是否有任何一个为空,并且您正在尝试使用该对象属性.处理相同. This error happens when you try to use a property of an object that is null. More details: here[^] A simple use of Visual studio DEBUGGER can tell you the object because of which it is happening. Just look at the stack trace and put a debugger on that line. Check the objects of that line and see if any one is null and you are trying to use that objects property. Handle the same.

更多推荐

以编程方式登录的问题

本文发布于:2023-11-30 13:44:46,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1650202.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:方式

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!