Note that there are some explanatory texts on larger screens.

plurals
  1. PO"Object reference not set to an instance of an object" Error
    primarykey
    data
    text
    <p>Im Having Problems Figuring Out Why I am Receiving an "Object reference not set to an instance of an object" Error in the Presentation Layer with this line:</p> <p><strong>TempAccountManager.Accounts.Add(tempAccount);</strong></p> <p>I Have Walked Through the Code With Visual Studios Debugger and the Account Gets Created. I Believe I Have an Issue With an Access Modifer, Not Sure.</p> <p><strong>Presentation Layer</strong></p> <pre><code>using myBudget.BusinessObject; using myBudget.BusinessLogic; namespace myBudget { public partial class NewBudgetWizard : Form { public int CurrentStep { get; set; } public Account TempAccount = new Account(); public AccountManager TempAccountManager = new AccountManager(); public NewBudgetWizard() { private void createAccountList(ListView lvAccounts) { foreach (ListViewItem lvi in lvAccounts.Items) { int tempAccNumber = Int32.Parse(lvi.SubItems[0].Text); string tempAccName = lvi.SubItems[1].Text; string tempAccType = lvi.SubItems[2].Text; decimal tempAccBalance = decimal.Parse(lvi.SubItems[3].Text, System.Globalization.NumberStyles.Currency); Account tempAccount = new Account(tempAccNumber, tempAccName, tempAccType, tempAccBalance, DateTime.Now); TempAccount = new Account(tempAccNumber, tempAccName, tempAccType, tempAccBalance, DateTime.Now); TempAccountManager.Accounts.Add(tempAccount); } } } } </code></pre> <p><strong>Business Logic Layer</strong></p> <pre><code>using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Collections; using myBudget.BusinessObject; namespace myBudget.BusinessLogic { public class AccountManager : Account { public List&lt;Account&gt; Accounts { get; set; } } } </code></pre> <p><strong>Business Object</strong></p> <pre><code>using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace myBudget.BusinessObject { public class Account { public int AccountID { get; set; } public int UserID { get; set; } public int Number { get; set; } public string Name { get; set; } public string Type { get; set; } public decimal Balance { get; set; } public DateTime ReconcileTimeStamp { get; set; } public Account() { } public Account(int number, string name, string type, decimal balance, DateTime reconcileTimeStamp) { Number = number; Name = name; Type = type; Balance = balance; ReconcileTimeStamp = reconcileTimeStamp; } } } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload