w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
IOrderedEnumerable returning NullReferenceException
You should add .Value when ordering on attribute. You wanna sort by ID's value, don't you ? The strange thing is that I've got an ArgumentException with your code (at least one object must implement IComparable), not a NRE... Items = myxml.Element("Values") .Elements("Item") .OrderBy(x => x.Attribute("ID").Value); or if you want numeric sorting OrderBy(x => Convert.ToInt32(x.Attribute("ID").Value);

Categories : C#

WPF NullReferenceException when XAML element is referenced in code
Put myOnlyGrid.Children.Add(MyChart); after InitializeComponent() myOnlyGrid gets created and initialized only in InitializeComponent call and before that line it's simply null so you are basically calling null.Children.Add(MyChart) which gives NullReferenceException

Categories : C#

jquey .next() not returning next element
Use nextAll(): DEMO function open_input(inputObj){ if(!$(inputObj).length) return; var spanObj = document.getElementById('s' + inputObj.id) inputObj.style.display = 'block'; spanObj.style.display = 'none'; inputObj.click(); setTimeout(function(){inputObj.focus()},0); } function next_cell(inputObj){ console.log(inputObj); var next_inputObj = $(inputObj).closest('td').nextAll('td').find('.inputfield')[0]; open_input(next_inputObj) }

Categories : Jquery

Returning a function if an element exists
use vanilla JS console.time('t'); document.querySelector('.label-key'); console.timeEnd('t') t: 0.000ms console.time('t'); $('.label-key'); console.timeEnd('t') t: 1.000ms Check out jsPerf Also Do it the other way around. check if the element doesn't exist and then do stuff. If it does just leave it alone. $(function() { //logic will execute if (! document.querySelector('.label-key'); ){ //logic will execute if search doesn't find span.myspan } }); more of a style thing really.

Categories : Javascript

Malloc returning one-element array
in my experience is always useful, when you ask for memory space, to put the size of what you are going to store multiplied by the amount of items you'll have. For example if you want an array of ints I would do: int *my_ints; my_ints = (int*) malloc(20*sizeof(int)); in your case arraystuffs = (uint8_t *) malloc(update_size*sizeof(uint8_t));

Categories : C

JavaScript not returning the right value (position of an element)
You included the tag jQuery in your question, so I assume you are already using it. I'd recommend using the function .position() for this, which should return the X and the Y coordinates of your password input: var p = $('#password').position(); console.log("x=" + p.left + "; y=" + p.top); If you are not using jQuery, element.getBoundingClientRect() is fine, but it doesn't have the cross-browser fixes jQuery provides.

Categories : Javascript

Array deserialization only returning 1 element
I do not see any issue. I've even reproduced your scenario (complete test enclosed below) of your code, and it is doing its job correctly. Try to search elsewhere (e.g. assure that the passed xml is the one you are expecting). But serialization is working correctly with your C# class mapping EDIT: AuthHash class no does the conversion for you from byte[] to base64 and back public class ServerConnections { public ServerConnectionEntry[] Entries { get; set; } } public class ServerConnectionEntry { public string Name { get; set; } public AuthHash AuthHash { get; set; } } public class AuthHash { [XmlIgnore] public byte[] Hash { get; set; } public string base64Binary { get { return Convert.ToBase64String(Hash); } set { Hash = Convert.FromBase64Str

Categories : C#

Why isn't jQuery selector returning an object instead of an element?
Because $("<a href="#" />") is NOT a selector You are creating a new anchor element Other than that, your code seems to be correct. See jsFiddle Update Unfortunately, I am unable to reproduce the error Uncaught TypeError: Object[object Object] has no method 'on' But if you have changed $.fn.showPartnerTabs() to showPartnerTabs(), the this line $(this).showPartnerTabs(); will throw this error Object [object Object] has no method 'showPartnerTabs' Please make sure the following is true $ is actually jQuery and not any other library i.e. console.log($("<a href="#" />") instanceof $) prints true or console.log($==jQuery) prints true You are using jQuery 1.7+ because earlier versions have no support for .on

Categories : Jquery

Generalized programming for returning the element of a nearest to val
With your existing code, if you may want to convert it into generic, the code would look similar to below: import java.util.Arrays; public final class Selector { private Selector() { } public static <T> T nearest(Collection<T> c, T val, Telemeter<T> tm) { if (c == null || c.isEmpty()) { throw new IllegalArgumentException("a is null or has zero-length"); } int idx = 0; double distance = tm.distance(c.get(0), val); for (int i = 1; i < c.size(); i++) { double cdistance = tm.distance(c.get(i), val); if (cdistance <= distance) { idx = i; distance = cdistance; } } int theNumber = c.get(idx); return theNumber; } }

Categories : Java

Make function wait before getting and returning DOM element
Take a look at waitfor.js. You can set a timer to wait for the element to appear. Your code will look something like: it('should display error message string for bad credentials', function(done) { page.evaluate(function() { document.querySelector('input.form-input[type="text"]').value = 'foo@bar.com'; document.querySelector('input.form-input[type="password"]').value = 'wrongpass'; document.querySelector('input.form-action-b').click(); }); waitFor(function() { // wait for 'div.status-oops p' to appear return page.evaluate(function() { return document.querySelector('div.status-oops p').is(":visible"); }); }, function() { // on appearance, grab the innerText and compare it to the desired value resu

Categories : Javascript

WCF method is returning empty message element
Maybe it will work if you declare this as a "bare" service: [SoapDocumentService(Use = SoapBindingUse.Literal, ParameterStyle = SoapParameterStyle.Bare)] Otherwise implement a custom message inspector (and if it dows not work then a custom message encoder) to change the message.

Categories : Asp Net

returning an element extracted from a monad; redundant?
In short, yes. To prove it: You've written: xss >>= (xs -> xs >>= x -> return x) xss >>= (xs -> xs >>= return) -- eta in the first and xss >>= (xs -> xs) xss >>= id according to the monad laws, return is a right identity so that m >>= return === m so we can do xss >>= ( xs -> xs >>= return ) xss >>= ( xs -> xs ) xss >>= id

Categories : Haskell

add class to element returning unexpected results
I tested your javascript function using Twitter bootstraps css classes and it works without a problem. Here is my jsfiddle code: http://jsfiddle.net/yqRCX/ Here are the css classes: .alert { padding: 8px 35px 8px 14px; margin-bottom: 20px; text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5); background-color: #fcf8e3; border: 1px solid #fbeed5; -webkit-border-radius: 4px; -moz-border-radius: 4px; border-radius: 4px; } .alert, .alert h4 { color: #c09853; } .alert h4 { margin: 0; } .alert .close { position: relative; top: -2px; right: -21px; line-height: 20px; } .alert-success { color: #468847; background-color: #dff0d8; border-color: #d6e9c6; } .alert-success h4 { color: #468847; } .alert-danger, .alert-error { color:

Categories : Javascript

Selecting nth element using xpath is returning more results then expected
What your query was doing was checking that the element was a first child, not that it was the first of the result node-set. This should work as intended: (//div[contains(concat(" ", normalize-space(@class), " "), " sub-category-wrap ")])[1]/dl/dt

Categories : HTML

Select element not returning webelement from .first_selected_option() method
Are you missing a closing parenthesis at the end of the option = Select(... line? Perhaps this is what you are looking for: Selenium - Python - drop-down menu option value self.driver.find_element_by_id("select_foo_bar") should already return the element, can you just call self.driver.find_element_by_id("select_foo_bar").first_selected_option()?

Categories : Python

NullReferenceexception using glimpse
I just came across this issue today. Turns out it simply that I needed to update the Glimpse NuGet packages as I was using versions that were no longer supported by the newer MVC / ASP.NET technology. After this, I got a runtime error relating to the System.Web.Mvc.Html reference in my Web.Config. This was subsequently fixed by Cleaning my solution then changing the "Copy Local" property against the System.Web.Mvc reference to True.

Categories : Asp Net

Unity: NullReferenceException
It seems that either Main is null or you didn't call Towers.Start() before the line causing the problem. When initialising static fields like that, it can sometimes be better to use static initialisation where you declare the fields, by calling a private static method that returns the initialisation data. Doing that means that you don't need a separate Start() method that you must remember to call. For example: public class Towers: MonoBehaviour { public static float[] d = initD(); public static float[] r = initR(); public static float[] s = initS(); public static float[] u = initU(); private static float[] initD() { return new [] { 1f, 3f, 5f, 7f, 9f, 11f,

Categories : C#

How to get rid of NullReferenceException error
You need to check if PropertyChanged is null: if (PropertyChanged != null) { PropertyChanged(this, new PropertyChangedEventArgs("AboveAircraft")); } It will only be not null if there is at least one handler registered elsewhere.

Categories : C#

Confusion about NullReferenceException
So those two calls to Console.WriteLine() are the same right ? No. Because Console.WriteLine doesn't call ToString on a null reference - it just uses the empty string instead. It detects that itself. The documentation explicitly states this: If value is null, only the line terminator is written. Otherwise, the ToString method of value is called to produce its string representation, and the resulting string is written to the standard output stream. With no call to ToString, there's no NullReferenceException. string.Format behaves the same way. For example: object value = null; string text = string.Format("Value: '{0}'", value); will set text to Value: ''

Categories : C#

NullReferenceException was caught...?
Change crtCommand.ExecuteScalar().ToString() to (crtCommand.ExecuteScalar() ?? string.Empty).ToString(). This is logically equivalent to: object dbResult = crtCommand.ExecuteScalar(); if(dbResult == null) { richTextBox1.AppendText(";"); } else { richTextBox1.AppendText(dbResult.ToString() + ";"); } If you want to completely ignore a null result instead of treating it as an empty string, use @SimonWhitehead's code

Categories : C#

NullReferenceException after POST
As the error is trying to tell you, Model.ClientList is null. You need to initialize the model, just like you did in the GET action. (for example, by calling the same function)

Categories : C#

InputBox NullReferenceException
do as below public InputBox(string title, string question) { InitializeComponent(); this.Text = title; Label1.Text = question; } first Initialize the Components, after that you can set properties

Categories : C#

ServiceStack NullReferenceException
I can't see your images class but I think you need to change ROUTES.Add<images>("/Images"); To ROUTES.Add<ImageRequest>("/Images") since the Post on your ImageService is looking for a request of type ImageRequest.

Categories : Asp Net Mvc

Delegater NullReferenceException
this public MessageRepository repository = new MessageRepository(); not that MessageRepository mr = new MessageRepository(); mr.SetDelegater(informer); You should make sure repository is initialized properly (did you forget to assign mr to <object>.repository?).

Categories : C#

NullReferenceException in DbContext.saveChanges()
Problem solved. The cause was a bit silly. I was using the default ASP.NET Web Forms Application project from VS Web Express to perform my testing. This project contains a web form called Contact.aspx, so it already includes a partial class Contact in the same namespace as my Contact entity. Understandably, this didn't play well with Entity Framework, leading to the rather obscure error above. Deleting the aspx page solved the problem.

Categories : C#

NullReferenceException in embeded if clause
If this is getting a NullReferenceException: if (@DQL.CheckUsernameAndEmail(Model.username, Model.email)) Then it's either because DQL is null, Model is null, or some code in CheckUsernameAndEmail is throwing that exception. We don't have enough context in this question to know what DQL is, and the population of your model is done in your controller action, which is not posted in this question. Posting CheckUsernameAndEmail's code may also help. Basically, any time you get NullReferenceException it means you have a null reference. Update Thanks for the updated information! If you don't want your Model to be null when executing your Razor view, make sure to add a model to your ViewResult: [HttpGet] public ActionResult SendMail() { var model = new ContactAdminViewModel(); // P

Categories : Javascript

Why do I get the error "NullReferenceException was unhandled"?
Your pictureBox1.Paint event is raised before your Form1.Load event. Move myBoard = new SlidePuzzle(rowsCols, tileSize, imageList1); to your constructor and you should be fine.

Categories : C#

error c# System.NullReferenceException
I think in case fromDate == toDate your sql function don't returns any values. So, you cannot call NULL.FirstOrDefault() var result = sqlQuery.List<object[]>().Select(row => new OrderTotalModel() { TotalQuantity = (double)row[0], TotalAmount = truncateAmount.truncateAmt((double)row[1]), }).FirstOrDefault();

Categories : C#

Exception NullReferenceException in controller (asp.net mvc)
Your Users list are not initialized. Create a new list before accessing it Users = new List<UserRow>(); You can change the SupplierRow class: public class SupplierRow { private List<UserRow> users = new List<UserRow>(); public List<UserRow> Users { get { return users; } set { users = value; } } ... } or in the constructor: public class SupplierRow { public SupplierRow() { Users = new List<UserRow>(); } public List<UserRow> Users { get; set; } ... } or before accessing it: foreach (UserRow ur in users) { foreach (SupplierRow sr in suppliers) { sr.Users = new List<UserRow>(); if (ur.SupplierId == sr.Id) { sr.Users.Add(ur); }

Categories : Asp Net Mvc

NullReferenceException when inserting with Dapper
It sounds like one of the properties is null. Split the code: var args = new {BugId = fogbugzCase.BugId, Title = fogbugzCase.Title, ProjectId = fogbugzCase.Project.Id, CategoryId = fogbugzCase.Category.Id, RootId = fogbugzCase.Root, MilestoneId = fogbugzCase.Milestone.Id, Priority = fogbugzCase.Priority, StatusId = fogbugzCase.Status.Id, EstimatedHours = fogbugzCase.EstimatedHours, ElapsedHours = fogbugzCase.ElapsedHours, PersonAssignedToId = fogbugzCase.PersonAssignedTo.Id, PersonResolvedById = fogbugzCase.PersonResolvedBy.Id, IsResolved = fogbugzCase.IsResolved, IsOpen = fogbugzCase.IsOpen, Opened = fogbugzCase.Opened, Resolved = fogbugzCase.Resolved, Uri = fogbugzCase.Uri, OutlineUri = fogbugzCase.OutlineUri, Spec = fogbugzCase.Spec, ParentId = fogbugzCase.ParentId, Backlog = fogbugzC

Categories : C#

NullReferenceException - Need to Update Field
It's probably because the FindControl method is returning null references (if I remember correctly, I'm talking about the nothing value in VB). That would mean the controls aren't being stored in the row, so check that.

Categories : Vb.Net

Itextsharp export to pdf NullReferenceException
Although you can write directly to the Response.OutputStream, doing so can mask errors sometimes. Instead I really recommend that you write to another stream such as a FileStream or MemoryStream. If you use the latter you can also then persist the MemoryStream to a byte array that you can pass between functions. The code below shows this off as well as using the dispose pattern on disposable objects. //We'll use this byte array as an intermediary later Byte[] bytes; //Basic setup for iTextSharp to write to a MemoryStream, nothing special using (var ms = new MemoryStream()) { using (var document = new Document()) { using (var writer = PdfWriter.GetInstance(document, ms)) { document.Open(); //Create our HTML worker (deprecated by the way) HT

Categories : C#

Unity3D getting a NullReferenceException for a split second
Since you already hold a reference to your EnemyAI script in myPlayerTargetScript you should check this for null in OnGUI Also don't use FixedUpdate for such things. FixedUpdate belongs to the physics system. Just use Update instead: #pragma strict var healthText : GUIText; var myPlayer : Transform; var myPlayerScript : PlayerScript; var myPlayerTarget : Transform; var myPlayerTargetScript : EnemyAI; function Start () { myPlayer = GameObject.FindGameObjectWithTag("Player").transform; myPlayerScript = myPlayer.GetComponent(PlayerScript); } function Update () { if (myPlayerScript.target != null) { myPlayerTarget = myPlayerScript.target; myPlayerTargetScript = myPlayerTarget.GetComponent(EnemyAI); } } function OnGUI () { if (myPlayerTargetScript

Categories : Unity3d

NullReferenceException thrown even though checking for Nothing
Perhaps it isn't that thisValue is Nothing, it is the fact that .ToString() is returning Nothing? Try this code to test it out: Public Overridable Function Comparer(thisValue As Object, otherValue As Object) As Integer Try If thisValue Is Nothing Then If otherValue Is Nothing Then Return 0 Else Return -1 End If Else If otherValue Is Nothing Then Return 1 Else Dim thisValueStr As String = thisValue.ToString() Dim otherValueStr As String = otherValue.ToString() 'HERE, CHECK THE TWO STRINGS FOR NULL!!! Return thisValueStr .CompareTo(otherValueStr ) End If End If Catch ex As

Categories : Vb.Net

Error: System.NullReferenceException
This seems to be the issue. listBox1.SelectedValue = l.SelectedIndex; txtName.Text = listBox1.SelectedValue.ToString(); SelectedValue is null and you're calling ToString which throws the exception. Why not just do txtName.Text = l.SelectedIndex.ToString(); Also, you're calling listBox1 directly as well as using l (listBox1.SelectedValue = l.SelectedIndex;). They both reference the same ListBox.

Categories : C#

Why ArgumentNullException? Why not System.NullReferenceException?
Count() is an extension method on IEnumerable<T>, declared in System.Linq.Enumerable - so you're actually calling: Enumerable.Count(_tables); ... so _tables is a method argument, and it makes sense for the exception to tell you that. You're not actually dereferencing the _tables variable when you call Count(), whereas you are when you call GetType.

Categories : C#

NullReferenceException was Unhandled - No idea why
You're accessing Content before it's set - or, rather, you're never setting it at all. Change public TestLevel(int width, int height) { //I input my screen dimensions as my level size to public TestLevel(int width, int height, ContentManager myContent) { content = myContent; //I input my screen dimensions as my level size and then add the Content argument when you create your TestLevel object (I assume from Game1.cs) (Note: Be sure to create TestLevel after you create the Content object [in the LoadContent method]!) EDIT: For the new problem: You're not defining the contents of the array, except a single layer of grass... The line ground.Draw(gameTime, spriteBatch); Change to if (ground != null) { ground.Draw(g

Categories : C#

nullreferenceexception while creating window xaml
OK, so I found out what is happening, albeit on quite a high level, but it seems I can't start 2 ui's concurrently. As I stated in my question, I run the login ui and dashboard ui, and I start them in the way described above, that is start a thread with STA Apartment state, the new thread then new's the login window class and hands it over to the dispatcher. But after the new thread is started the main thread goes ahead and starts its work on the dashboard window in the same fashion and as it turns out, some part of that process cannot run concurrently with another thread. Not sure why, but thats how I resolved it. So basically the code for starting the ui's now look like this private AutoResetEvent _dashboardStartWaitEvent = new AutoResetEvent(false); internal void SetupAndRunDas

Categories : C#

Avoiding NullReferenceException in Request.QueryString
You can use the null-coalescing operator: bool isAdvancedMode = (Request.QueryString["mode"] ?? String.Empty).Equals("advanced"); Edit: If you want to re-use this logic, try this extension method: public static bool EqualIfExists(this string source, string comparison) { return source != null && source.Equals(comparison); } Request.QueryString["mode"].EqualIfExists("advanced") Add more overrides to match Equals signature. I'm not sure if this is a good name (I think it is not).

Categories : C#

VB.Net - "NullReferenceException was unhandled by user code"
The DataGridView or the DataGridView1.CurrentRow are null ... To avoid the error you can simply ensure that they are not null before attempting to access them : Dim a as Integer = 0 If DataGridView1 IsNot Nothing AndAlso DataGridView1.CurrentRow IsNot Nothing Then a = DataGridView1.CurrentRow.Index 'this certain line contains the error EndIf

Categories : Vb.Net



© Copyright 2017 w3hello.com Publishing Limited. All rights reserved.