Note that there are some explanatory texts on larger screens.

plurals
  1. POerror:The ObjectContext instance has been disposed and can no longer be used for operations that require a connection
    text
    copied!<p>i have a listbox and when i select an item from this listbox called as ListofKBrands1, i take this error message:</p> <blockquote> <p>The ObjectContext instance has been disposed and can no longer be used for operations that require a connection.</p> </blockquote> <p>In code-behind,place of this error:</p> <pre><code>if (co.Company != null) </code></pre> <p>my code:</p> <pre><code>private void ListofKBrands1_SelectionChanged(object sender, SelectionChangedEventArgs e) { RSPDbContext c = new RSPDbContext(); if (ListofKBrands1.SelectedItem != null) { ListBoxItem item = ListofKBrands1.SelectedItem as ListBoxItem; KBrand co = item.Tag as KBrand; if (ListofKBrands1.SelectedItem != null) txtNewKBrand.Text = co.Name; else txtNewKBrand.Text = ""; int count = 0; if (co.Company != null) { foreach (string a in cbCompany.Items) { if (a == co.Company.Name) cbCompany.SelectedIndex = count; count++; } } else cbCompany.SelectedIndex = 0; } } </code></pre> <p>before error:</p> <p><img src="https://i.stack.imgur.com/Cz3gu.png" alt="enter image description here"></p> <p>my KBrand.cs:</p> <pre><code>public class KBrand { [Key] public int Id { get; set; } public String Name { get; set; } public virtual Company Company { get; set; } public override string ToString() { return Name; } } </code></pre> <p>company.cs:</p> <pre><code>public class Company { [Key] public int Id { get; set; } public String Name { get; set; } public override string ToString() { return Name; } } </code></pre> <p>if company of selected KBrand is null, this error does not appear. but if company of selected KBrand is not null, i take this error.how can i fix this error ? thanks in advance.</p>
 

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