Questions tagged [invalidoperationexception]

The exception that is thrown when a method call is invalid for the object's current state.

The exception that is thrown when a method call is invalid for the object's current state.

More information is available on Docs.

505 questions
2
votes
2 answers

XmlSerializer System.InvalidOperationException

I have the following code in my application: [Serializable] public class Class { private string name = ""; private List property = new List(); [XmlAttribute] public string Name { get { return name; } …
Mitja
  • 863
  • 5
  • 22
2
votes
2 answers

InvalidOperationException: Sequence contains no elements

I have written a code in .net using mvc and entity framework: @{ List oldProjectList = new BL.ProjectLogic().getProjects(userName).Where(s => s.Status == "Not Active").ToList(); } @foreach (DAL.Project p in oldProjectList) { …
Ago
  • 313
  • 1
  • 2
  • 10
2
votes
3 answers

WPF DependencyObject calling thread exception

I have the following code which creates a temporary folder and uses a FileSystemWatcher to poll for files added to the folder on the Location property, and add them to a list: Scratchdisk.cs on Pastebin. The idea is to create a Scratchdisk object,…
2
votes
1 answer

When Adding Data Annotation Attribute it's throwing Exception

public class Employee { [Key] public int Id { get; set; } public string Name { get; set; } public string Address { get; set; } public decimal Salary { get; set; } public string Email { get; set; } } public class…
2
votes
1 answer

Changing Combobox item in code-behind throws invalidoperationexception

I have several comboboxes which are initialiced with a default text which will be replaced later on by textes out of a text-file to support different languages. I tried different ways to change the text but none of them worked…
e_card
  • 119
  • 2
  • 10
2
votes
1 answer

I get InvalidOperationException when I try to use Metadatatype with a viewmodel

I have a model with certain properties. I use a separated class with the MetadataType to define requirements for properties. I also try to use the same metadata class with a viewmodel defining just a subset of properties. This is a simple example…
2
votes
1 answer

ITextSharp upgrading from 5.3.3.0 to 5.5.0.0 merge files issue - Already closed on document close

Here's my code: public static byte[] MergePdf(List pdfs, float scaleFactor) { int n=0; //Removes the null pdf documents from the list while(n < pdfs.Count) { if (pdfs[n]…
2
votes
0 answers

How to debug System.InvalidOperationException in System.Security.AccessControl.Privilege.Revert()

I have an application that suddenly started crashing when it is shutting down with the following error in the Event Log: Application: App.exe Framework Version: v4.0.30319 Description: The process was terminated due to an unhandled…
BrutalDev
  • 6,181
  • 6
  • 58
  • 72
2
votes
0 answers

Failure to launch VB.net application on distributed machines

I'm not entirely sure what's going on with this. The application works absolutely fine on my machine, but when being launched on another machine, it crashes at launch. This is the error log of the .NET Runtime: Log Name: Application Source: …
2
votes
1 answer

InvalidOperationException Error Reflecting Class

After read multiples posts related on this error and not found an solution to my problem, I explain it here. I use XmlSerializer to serialize simple classes. Here's my code: private void btnGenerateXml_Click(object sender, RoutedEventArgs e) …
2
votes
1 answer

System.InvalidOperationException with SQlBulkCopy

I got the following error when executing bulkcopy. System.InvalidOperationException The given value of type String from the data source cannot be converted to type decimal of the specified target column. I use the following code. DataTable…
ACP
  • 34,682
  • 100
  • 231
  • 371
2
votes
2 answers

Enumerating a collection, then modifying it, what is the precedent for throwing an exception?

When enumerating a .NET collection, MSDN states that: An enumerator remains valid as long as the collection remains unchanged. If changes are made to the collection, such as adding, modifying, or deleting elements, the enumerator is irrecoverably…
Lasse V. Karlsen
  • 380,855
  • 102
  • 628
  • 825
2
votes
1 answer

Web API throws exception after installing AttributeRouting

I developed a simple VB .NET Web API project using .NET 4.5 This project was working perfectly fine, but I decided to install the AttributeRouting nuget package. After installing this package every function seems to raise the following…
Jelle
  • 98
  • 1
  • 7
2
votes
0 answers

July 2013 AjaxControlToolkit.ToolkitScriptManagerCombiner Errors

Hello we are recieving a few different errors on our surver after we upgraded to the July 2013 version of AjaxControlToolKit. It appears if the users go back to the previous screen and attempt to execute the same process they previousily did, they…
2
votes
2 answers

Iterating over a growing dictionary

I am working with C# and I have a dictionary called intervalRecordsPerObject of type Dictionary>. I need to iterate through the dictionary. The problem is: everytime I iterate through the dictionary, more KeyValuePairs may…
akaHuman
  • 1,332
  • 1
  • 14
  • 33