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
1 answer

Setting the target of an animation to a custom user control created at runtime

I'm using a custom control to display news data. I store the control in codebehind so I can display it without having to reload the information (takes anywhere from 2-5 seconds to perform all the tasks associated with populating the control). The…
Nathan Brown
  • 311
  • 1
  • 3
  • 12
2
votes
1 answer

Error:A referential integrity constraint violation occurred on db.SaveChanges() in .net?

I have a created a WPF application with Entity framework 4.0. When i am trying to insert record in PhoneNumber Table it inserts first record successfully. But, when i loop through some List and try to insert another item into PhoneNumber table it…
2
votes
1 answer

F#: InvalidOperationException: The input sequence has an insufficient number of elements?

I have a function which returns a sequence of records. In that function I start the list building with a blank dummy record (there is probably a better way to do it) because I need to accumulate records that are similar, so I "prime the pump" with…
User
  • 62,498
  • 72
  • 186
  • 247
2
votes
0 answers

Getting InvalidOperationException during call to GetResponseAsync()?

PREFACE: I know the code excerpt is lengthy but I did't want to leave out a detail that someone else might spot as the cause of the issue. The reason for the somewhat verbose nature of the code and the many Exception traps is due to the hunt for…
2
votes
3 answers

InvalidOperationException on object from a thread that's done

In a WPF application I had a BackgroundWorker thread creating an object. Let's call the object foo. Background worker code: SomeClass foo = new SomeClass(); // Do some operation on foo // Set some dependency property on the main class to…
2
votes
1 answer

Delayed-Load DataGridView with customized columns

I just created a test project to debug an issue i ran into, and can't seem to understand what's going on in here... In this test project, i have just a Form, a TabControl, and a DataGridView (called dgvTest) in a "background" page within the…
C.B.
  • 666
  • 3
  • 18
2
votes
2 answers

A first chance exception of type 'System.InvalidOperationException' occurred in PresentationFramework.dll

All, I'm using DataBase First Entity Framework v4.4. In the DB (and data model) is Table1 that has a 1:many relationship to Table2. I am binding a DataGrid in WPF to Table1.Local.First().Table2 (for simplicity, assume that there is an entity in…
William
  • 551
  • 2
  • 10
  • 24
2
votes
1 answer

Window.Loaded - ShowDialog() - Cannot Perform Operation

Description Hi, I've been searching the web for information on this and didn't find anything that would lead to it being fixed. I want to show a dialog when my main window loads and thus I assigned an event handler to my MainWindow's Loaded event.…
zeluisping
  • 213
  • 7
  • 17
2
votes
1 answer

DataGridView control must be bound to an IBindingList object to be sorted

I have a custom control inherited from DataGridView that I'd like to be able to just copy the .cs file for, and drop it in to any project. There's one bit of code that I can't manage to move out of Main.cs, and into DataGridView.cs though: private…
Danny Beckett
  • 20,529
  • 24
  • 107
  • 134
2
votes
2 answers

InvalidOperationException: Collection was modified; refers to which collection?

I often find it's not really specified what exact collection is causing this type of exception. Is that true or should it be obvious? Perhaps I just don't understand how to interpret the exception message properly.. Specifically I wonder about this…
bretddog
  • 5,411
  • 11
  • 63
  • 111
2
votes
1 answer

InvalidOperationException if the process is started as a default associated program for a file type

Situation: I spawn processes for various file types (pictures, Word documents, etc) by relying on the default associated handler program. This means that I only specify the particular file name as the StartInfo.FileName, and no actual executable…
Csaba Toth
  • 10,021
  • 5
  • 75
  • 121
2
votes
1 answer

How to handle error when two apps are using BackgroundAudioPlayer

This is another background audio resources are no longer available error in Windows Phone 7, but a different scenario. I have 2 apps, which both use BackgroundAudioPlayer to play background music. When app A is playing background music, I press Home…
2
votes
1 answer

getting error - System.InvalidOperationException was unhandled

I have just started to learn windows application development, and we have been given self learn project to develop one windows application. I am trying to create the application to send email. I have created a class MsgSender.cs to handle that. When…
android_newbie
  • 667
  • 2
  • 14
  • 32
2
votes
2 answers

Locking does not prevent InvalidOperationException: Object is currently in use elsewhere

I was under the impression that lock() would prevent multiple threads from accessing an object simultaneously. But, an InvalidOperationException (Object is currently in use elsewhere) is still frequently thrown by the following code: lock (this) { …
Tom Wright
  • 11,278
  • 15
  • 74
  • 148
2
votes
1 answer

Compiling a Delegate with Expression.Lambda() - Parameter Out Of Scope, but is it really?

I came across an interesting problem today whilst implementing a feature into a dynamic expression building library. More specifically, but irrelevantly, a feature to define operator precedence in an expression. When the LINQ engine was compiling…
Rabid
  • 2,984
  • 2
  • 25
  • 25