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
8
votes
3 answers

Starting and Forgetting an Async task in MVC Action

I have a standard, non-async action like: [HttpPost] public JsonResult StartGeneratePdf(int id) { PdfGenerator.Current.GenerateAsync(id); return Json(null); } The idea being that I know this PDF generation could take a long time, so I just…
8
votes
3 answers

Modifying Collection when using a foreach loop in c#

Basically, I would like to remove an item from a list whilst inside the foreach loop. I know that this is possible when using a for loop, but for other purposes, I would like to know if this is achievable using a foreach loop. In python we can…
Lloyd Powell
  • 18,270
  • 17
  • 87
  • 123
8
votes
3 answers

PerformanceCounter.NextValue() throws InvalidOperationException

This is the code that creates the performance counter: var ftpPerfCounter = new PerformanceCounter("FTP Service", "Current Connections", "_Total"); This is where the exception happens: int cnt = (int)Math.Round(ftpPerfCounter.NextValue()); Here's…
7
votes
1 answer

asp.net-mvc3 EditorFor template name issue

i'm having a strange issue regarding the editorFor helper from MVC3. Here's the thing: i'm trying to display a checkboxList and it works if i don't call explicity the template name. However if i try to use the template name, it throws an exception…
AdrianoRR
  • 1,131
  • 1
  • 17
  • 36
7
votes
6 answers

DataGrid 'EditItem' is not allowed for this view when dragging multiple items

I have a datagrid which gets data like this: public struct MyData { public string name { set; get; } public string artist { set; get; } public string location { set; get; } } DataGridTextColumn col1 = new…
amitairos
  • 2,907
  • 11
  • 50
  • 84
7
votes
5 answers

What are the reasons Process.HasExited can throw InvalidOperationException?

I'm seeing a System.Diagnostics.Process.HasExited method throw an InvalidOperationException, but the message text property is not terribly useful as to why it was thrown. Under what conditions does this exception get thrown?
Robert Davis
  • 2,255
  • 2
  • 21
  • 21
6
votes
2 answers

When is a good time to throw InvalidOperationException?

I think I know what I mean about this but I am not quite sure... The Framework documentation summarizes the type as follows: The exception that is thrown when a method call is invalid for the object's current state. There are clear-cut cases, and…
The Dag
  • 1,811
  • 16
  • 22
6
votes
2 answers

What means an InvalidOperationException on Process.ExitTime "Process was not started by this object, so requested information cannot be determined."

We have a tool that manages several processes of a computer and from time to time in uncertain conditions we get an InvalidOperationExceptionwhen accessing the MSDN: Process.ExitTime property. The exception message says process was not started by…
Ignacio Soler Garcia
  • 21,122
  • 31
  • 128
  • 207
6
votes
4 answers

VB.net ApplicationFramework plus SplashScreen: InvalidOperationException

I recently changed my app from using a custom SplashScreen (it was just a Form with a Timer loaded the main form and closed itself) to the Application Framework. Here is what I did: Created a new SplashScreenForm that shows the app version…
Jürgen Steinblock
  • 30,746
  • 24
  • 119
  • 189
6
votes
2 answers

Data grid view CellValueChanged event throwing InvalidOperationException

throwing InvalidOperationException when I changed cell value for update and directly click on menu strip item for open new Winform. private void dgv_category_CellValueChanged(object sender, DataGridViewCellEventArgs e) { …
6
votes
3 answers

The current types, IUserStore and DbConnection, are respectively an interface and abstract class and cannot be constructed

If I surf to http://localhost:58472/Account/Register I've this exception System.InvalidOperationException: The current type, IUserStore, is an interface and cannot be constructed. Are you missing a type mapping? Here is my…
6
votes
2 answers

WPF DataGrid ComboBox causes InvalidOperationException

I am getting an InvalidOperationException('DeferRefresh' is not allowed during an AddNew or EditItem transaction.) from my datagrid when I try to edit the value of a combo box column. The items I am showing all have a reference to one other item in…
aalex675
  • 421
  • 1
  • 7
  • 15
6
votes
0 answers

.Net Framework Data Provider error 60

I've received the following error from the live site: System.Web.HttpUnhandledException: Exception of type 'System.Web.HttpUnhandledException' was thrown. ---> System.InvalidOperationException: Internal .Net Framework Data Provider error 60.…
6
votes
10 answers

ASP.NET Web Method that accepts a List is failing with "Web Service method name is not valid."

I want to create a web method that accepts a List of custom objects (passed in via jQuery/JSON). When I run the website locally everything seems to work. jQuery and ASP.NET and everyone is happy. But when I put it on one of our servers it blows…
Bara
  • 1,113
  • 6
  • 18
  • 28
6
votes
1 answer

.NET xsd importer creates unserializable class

I am using the .NET XSD.EXE importer to generate C# classes from a collection of XSD files. When I tried to serialize one of the classes to XML it failed (InvalidOperationException), and when I dug into it I discovered it one of the created classes…
Jim McKeeth
  • 38,225
  • 23
  • 120
  • 194
1 2
3
33 34