nullreferenceexception

MVC5 / C# - Cannot perform runtime binding on a null reference

自闭症网瘾萝莉.ら 提交于 2020-05-29 11:03:08
问题 I'm trying to figure out what's causing a Cannot perform runtime binding on a null reference error from this code: var query = "SELECT Id, UserName, List_Order, LoggedIn " + "FROM AspNetUsers" + "WHERE LoggedIn = 1" + "ORDER BY List_Order ASC"; var conn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["DefaultConnection"].ConnectionString); var cmd = new SqlCommand(query, conn); conn.Open(); var rdr = cmd.ExecuteReader(); var n = 0; while(rdr.Read()) { if

What is a NullReferenceException, and how do I fix it?

╄→尐↘猪︶ㄣ 提交于 2020-04-30 11:07:11
问题 This question's answers are a community effort . Edit existing answers to improve this post. It is not currently accepting new answers or interactions. I have some code and when it executes, it throws a NullReferenceException , saying: Object reference not set to an instance of an object. What does this mean, and what can I do to fix this error? 回答1: What is the cause? Bottom Line You are trying to use something that is null (or Nothing in VB.NET). This means you either set it to null , or

NullReferenceException when debugging and using invoke

回眸只為那壹抹淺笑 提交于 2020-04-16 05:15:31
问题 I found an interesting behavior yesterday while debugging a Windows Forms application, please refer to this code: bool enter = false; Debugger.Break(); if (enter) // Force to enter the if clause, read next comment { bool a = false; // Bypass previous IF check in debug using 'Set Next Statment (CTRL-SHIFT-F10)' here // Will throw null reference exception // If I don't use invoke everything works fine Invoke(new MethodInvoker(() => { a = true; })); } So if I force to enter an IF clause that was

Error in 'AddMessageEventListener' on GeckoFX

元气小坏坏 提交于 2020-02-03 01:53:22
问题 I want that my browser (GeckoFX) executes a .NET function when clicking on a button in my webpage. I have the following code: public Form1() { InitializeComponent(); AddMessageEventListener("myFunction", ((string s) => this.showMessage(s))); browser.LoadHtml ( @"<!DOCTYPE html> <html><head> <meta http-equiv=""Content-Type"" content=""text/html; charset=UTF-8""> <script type=""text/javascript""> function fireEvent(name, data) { event = document.createEvent('MessageEvent'); event

System.NullReferenceException: Object reference not set to an instance of an object [duplicate]

萝らか妹 提交于 2020-01-22 03:59:33
问题 This question already has answers here : Closed 8 years ago . Possible Duplicate: System.NullReferenceException: Object reference not set to an instance of an object look at my code if (ViewState["Edit"].ToString() == "new") { } else { row = _section.GetBannerEntry(ViewState["Edit"].ToString()); } I was getting the error on this line if (ViewState["Edit"].ToString() == "new") I replaced with if (ViewState["Edit"] != null && ViewState["Edit"].ToString() == "new") it works. Now I am getting the

C# : “How to use WebBrowser and print the html to the console. ”

醉酒当歌 提交于 2020-01-17 06:47:20
问题 I have for plus 10 hours now tried to get a hole through to the WebBrowser property. I am simply trying to navigate to google.com and print the html code to the console. This constantly gives me a null reference. There is alot of questions related to this and they all say that a DocumentCompleted Eventhandler is needed or not setup properly. So i tried this to the best of my ability though still no luck. I then went so far as to copy paste the official example from Microsoft I am still

C# : “How to use WebBrowser and print the html to the console. ”

霸气de小男生 提交于 2020-01-17 06:46:36
问题 I have for plus 10 hours now tried to get a hole through to the WebBrowser property. I am simply trying to navigate to google.com and print the html code to the console. This constantly gives me a null reference. There is alot of questions related to this and they all say that a DocumentCompleted Eventhandler is needed or not setup properly. So i tried this to the best of my ability though still no luck. I then went so far as to copy paste the official example from Microsoft I am still

What is a NullReferenceException, and how do I fix it?

ε祈祈猫儿з 提交于 2020-01-16 20:09:43
问题 This question's answers are a community effort . Edit existing answers to improve this post. It is not currently accepting new answers or interactions. I have some code and when it executes, it throws a NullReferenceException , saying: Object reference not set to an instance of an object. What does this mean, and what can I do to fix this error? 回答1: What is the cause? Bottom Line You are trying to use something that is null (or Nothing in VB.NET). This means you either set it to null , or

What is a NullReferenceException, and how do I fix it?

我们两清 提交于 2020-01-16 20:08:08
问题 This question's answers are a community effort . Edit existing answers to improve this post. It is not currently accepting new answers or interactions. I have some code and when it executes, it throws a NullReferenceException , saying: Object reference not set to an instance of an object. What does this mean, and what can I do to fix this error? 回答1: What is the cause? Bottom Line You are trying to use something that is null (or Nothing in VB.NET). This means you either set it to null , or

C# Object Reference not set to an instance of an object error [duplicate]

谁都会走 提交于 2020-01-16 01:11:13
问题 This question already has answers here : What is a NullReferenceException, and how do I fix it? (28 answers) Closed 5 years ago . I am getting the error in the title when I run this code during the Add method. The Add method should add the gameobject to a list called queue. GameObject is a class. GameManager is a class as well. queue is a list. I think this is the only code relevant. static void Main() { GameObject obj1 = new GameObject(); GameManager manager1 = new GameManager(); obj1.name =