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

lock used and there is no looping still, Exceptions System.InvalidOperationException: Collection was modified; enumeration operation may not execute

I have gone through similar looking questions, where answers are suggesting to use lock and not to modify List inside of foreach loop on the same collection, I have already taken care of these two. I have globally available List and there…
Amit
  • 1,821
  • 1
  • 17
  • 30
-2
votes
1 answer

how to perform sum() on two variables in laravel 5.2

$store_obj = new account; $x = \Auth::user()->id $old = account::where('id',$x)->first(); echo $old->wallet; $new = Input::get("update"); echo $new; $upd = sum($old,$new);// strucked here echo $upd;
-2
votes
3 answers

Why is this code considered a "possible 'System.InvalidOperationException'"?

Resharper suggested I change this code: if (getBeginDate) { return (DateTime)RptParamsFromDate; } ...to this: if (getBeginDate) { if (RptParamsFromDate != null) return (DateTime)RptParamsFromDate; } ...because, "Possible…
B. Clay Shannon-B. Crow Raven
  • 8,547
  • 144
  • 472
  • 862
-2
votes
1 answer

Getting "The model item passed into the dictionary is of type" Exception in MVC5 application

I see lots of these type of questions here, but the answers all seem to point to what I'm doing. Help!!! Here's the pieces of code: In the MVC5 controller, RegistrationController: using System; using System.Collections.Generic; using…
user3802434
  • 602
  • 1
  • 7
  • 14
-2
votes
2 answers

Removing an Item in a list

I'm programming in c#. I'm trying to remove an item from a List<> but when I remove the item I get this exception error: An exception of type 'System.InvalidOperationException' occurred in mscorlib.dll but was not handled in user code Additional…
Babak.Abad
  • 2,839
  • 10
  • 40
  • 74
-2
votes
1 answer

Perform an action when a process closes

First of all, I'm programming in Windows Forms Application. As the title describes, I want to perform an action when a process I started, will close. I've tried at first: Process s = new Process(); s.EnableRaisingEvents = true; s =…
avi12
  • 83
  • 1
  • 5
-2
votes
1 answer

'System.InvalidOperationException' occurred in Microsoft.Phone.ni.dll

I am making an app which records sounds. When clicking the mike button it is supposed to move to a new page. When I add a save button in the application bar of the new page and then run it, it throws this exception…
-3
votes
3 answers

BinarySearch - Failed to compare two elements in the array

So we recently migrated an application from .NET 1.1 to .NET 4.0. And with that, there was a bunch of compatibility issues which we had to fix. One of them is that a block of code is throwing the InvalidOperationException. Public Function…
Smiley
  • 3,207
  • 13
  • 49
  • 66
-4
votes
1 answer

Exception insert record to SQL Server in C# by stored procedure

I'm trying to insert a supplier to SQL Server but it always throws an exception on the line cmd.ExecuteNonQuery(). Really need some help!
Lam
  • 15
  • 2
-4
votes
3 answers

How to throw an exception on `float==float` operation?

Imagine that an inexperienced programmer tries to compare 2 floats for equivalence: a = 0.01 b = 0.1 ** 2 print(a == b) Is there any language that would throw an exception on such foolishness? Or a way to override the default behaviour in python…
Aprillion
  • 21,510
  • 5
  • 55
  • 89
1 2 3
33
34