I have run into a strange issue dealing with the SelectedValue property of a dropdown list. We were incorrectly setting the SelectedValue property to an invalid selection (zero), but we were not aware of this issue because the exception is not being thrown in development. In development, the code below executes with no problem, but in production it throws an error.
int val = GetValue(); // Note: The GetValue() method is incorrectly returning a 0
ddlDropdown.SelectedValue = val.ToString(); // This line should throw an error
There is no item with a value of 0 in the dropdown, in either the production or dev environments. However, in dev, when this code executes, it simply does nothing. The ddlDropdown.SelectedValue property is a "1" before the line executes and it remains a "1" after the line executes (even though the code is trying to set it to 0). But in production, an error is being logged every time ("ddlDropdown has a SelectedValue which is invalid..."). I've even tried setting the value of the dropdown in the immediate window - setting it to a valid value (a "3", for example) works, but setting it to "0" has the same result - it simply does nothing.
I've researched the error being thrown and I've found references to the error being thrown only during a postback, and not on initial page load. But this code is only called in places that are wrapped in a if (!IsPostBack) so it should only be called on initial page load.
I've fixed the code to no longer incorrectly set the value to 0, but I cannot verify that the fix will work in production since I can't replicate the error in my dev environment.
Can anyone figure out why this code would be throwing an error in production and not in development?
Related
I'm stuck on something in my Robot Framework project. When I hit a button from the 1st page after the login is done, another tab is opened, however, sometimes, the new window is not loaded and the code (robotframework) keep waiting for an answer.
To avoid getting an error when this situation happens, I want to solve it while the code still running, I want to know if there is any keyword that applies an action in case something is not done within a given lead time. In my case it would be to close the new window and repeat the previous step (hit the button from the first page again), therefore, it would be 2 actions in case the actions fails (lead time).
I have tried to use the keyword Run Keyword and Return Status, in my case the status would be false, however, since my code is kept waiting for an answer, the status is always True, therefore, it does not work for me.
I have read that there is a keyword named Run Keyword If Timeout Occurred however, it can be only used on Teardown`, therefore, I also don't know if it can applied.
I see you are trying to compare Boolean and String.
it's should be boolean and boolean run Keyword if ${status}==False.
I use the Microsoft ASP.Net AJAX framework for an autocompletion thingy on a text field (AutoCompleteExtender).
I'm getting an error :
Error during serialization or deserialization using the JSON
JavaScriptSerializer. The length of the string exceeds the value set
on the maxJsonLength property.
Several weird things about this error :
the error is thrown even when every single webservice in my solution return nothing (I altered them to return empty arrays) ;
in the web.config, jsonSerialization maxJsonLength is set to the maximum value of 2147483644, and the webservices in this page are supposed to return a few results ;
it says the source of the error is in a javascript function, but the function is never run, so the webservice is never actually called :
when I delete every AutoCompleteExtender and every call to any webservice from the page, it starts to throw me errors on "end if" inside the aspx. When I remove every "If" in the aspx, it crashes without telling me why. Fun !
<script type="text/javascript">
var tbEntrIdFonctionItemSelected = function(sender, e) {
$get('<%=Me.FormViewContact.FindControl("hdn_AgenceIdFonctionSearch").ClientID%>').value = e.get_value(); // source of the error
}
</script>
What do you think could be the cause of the problem ?
Thanks
OK, so after a bit of tracking, I noticed that a Telerik Combobox was the source of the error. And apparently, it was retreiving (using JSON, hence the error) the very small amount of 140.000 items. No big deal, right ? Hum.
I'm getting error while running a game I created with flex.
I know there has been some question about this, but my case is quite weird. I created a simple typing game that is running OK on my computer, but when I tried to deploy it online to facebook, I got those errors. I used code from the tutorial from adobe here http://www.adobe.com/devnet/facebook/articles/flex_fbgraph_pt4.html to deploy my flex game to facebook
This is the error message:
TypeError: Error #1009: Cannot access a property or method of a null object reference.
at FacebookUserStatusWeb/init()
at FacebookUserStatusWeb/___FacebookUserStatusWeb_Application1_creationComplete()
at flash.events::EventDispatcher/dispatchEventFunction()
at flash.events::EventDispatcher/dispatchEvent()
at mx.core::UIComponent/dispatchEvent()
at mx.core::UIComponent/set initialized()
at mx.managers::LayoutManager/doPhasedInstantiation()
at mx.managers::LayoutManager/doPhasedInstantiationCallback()
And here is snippet of the init() function:
protected var text1:String="Text to be typed"; //hard-coded temporarily
protected const TIMER_INTERVAL:int = 10;
protected var t:Timer = new Timer(TIMER_INTERVAL);
protected var topURL:String=ExternalInterface.call('top.location.toString');
protected function init():void
{
t.addEventListener(TimerEvent.TIMER, updateTimer);
ProblemText.text = new String(text1);
Facebook.init("<my app id>",loginHandler);
currentState = (topURL) ? "loggedout": "loggedoutonfacebook";
}
Some notes:
1.my app id is my facebook app id which I prefer not to show
2.ProblemText is a richtext which I placed the paragraph to be typed by the player.
3.I have deleted the method Application1_creationComplete() but it still appears at the error listing
And also I am curious about the errors other than the first two. What do they mean?
Ah, and if it is helpful, I can post some more of the code
First: You're only seeing one error. Everything you see below the #1009 error is your stack trace, not additional errors.
The stack trace basically tells you the series of things that happened prior to the error occurring, with the most recent at the top. This is useful because often things which happen prior to the actual error you see will contribute to said error.
Second: The null object reference is occurring because something in your init() function tried to access a property in an object that doesn't exist, or an object that doesn't exist. One (slightly messy but effective) way to debug this would be to drop some trace statements in the code to see how far it gets before barfing with the error -- the idea being to isolate the specific line that's causing the problem. Once you've done that, you need to work backwards to figure out why the object or property you're trying to use is null. It could be something simple, like a typo, or it could be more complex. You'll have to sleuth it out, one way or another =)
Good luck!
Finally got the bug. Just in case people have the same case with me, what exactly happened is at my computer I simulated the game with just one state, but when I'm deploying to facebook I have several states (loggedin,loggedout,etc). In the init() I tried to access ProblemText Label that is not present in the current state.
Object reference not set to an instance of an object
I am getting this error sometimes.
I have a page where I load questions and for some question system generate this error. Why do I get this error? Please help me.
It means that somewhere something dereferences a null reference. Crude example:
Foobar foo = null;
foo.DoSomething(); // this line will trigger a NullReferenceException
Here's what you can do:
compile in debug mode
run it until it crashes
examine the stack trace; it will tell you where the exception originates (unless you're doing stupid things like catching and rethrowing improperly). You may have to follow the chain of inner exceptions
if that doesn't provide sufficient information, step through your code with a debugger until right before the call that makes it crash. Examine any variables that might be null.
Once you have found the culprit, you need to find out why it is null and what to do about it. The solution can be one of:
fix incorrect program logic that causes something to be null that shouldn't be
check if something is null before dereferencing it
handle the exception at a point that makes sense, and translate it into something more meaningful (probably some sort of custom exception)
You got null reference and if it can't handle it will show that message.
It can caused by some case
The return value of a method is null
A local variable or member field is declared but not initialized
An object in a collection or array is null
An object is not created because of a condition
An object passed by reference to a method is set to null
I suggest you to track the null value using a debug mode
You get this error, whenever you are trying to make use of variable with Null value in it.
I have a weird problem, I get an object from my DB, like this:
var user = BLL.Managers.Users.UserTmpManager.GetUser((int)customerID);
when I debug that code, and expand the user object, for each property I see the error as I mentioned at this topic's title. What causes it ?
unfortunately, it is still not being resolved, as I thought at the beginning..
I got this too, when I hit a NullReferenceException from a 3rd party control.
In this one case, I found that if I set a breakpoint before I hit the exception, I could then single step through the rest of the code without seeing the problem.
No idea why, but this worked for me - in this case at least.