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

Failing to capture process name and exit code in Exited eventhadler

I have a pretty straight forward event handler on process exit that wants to log the process name and exit code. This code runs perfectly in my local machine (Windows 10 pro, 64 bit) no matter how I end the process (calling Kill(), End Task from…
techshree
  • 21
  • 3
2
votes
3 answers

How to differentiate between InvalidOperationException exception types?

How to detect the InvalidOperationException type Here is the inner exception message: System.InvalidOperationException: ExecuteNonQuery requires an open and available Connection. The connection's current state is closed. I need to detect exactly…
narouz
  • 195
  • 1
  • 2
  • 8
2
votes
0 answers

Object is currently in use elsewhere and System.InvalidOperationException

Hello i am using a picture Box with Visual Studio and C#, i have made snake and it runs but it crashes either right away or after x amount of time. I have read up on the problem and it is because i am using a timer to draw on the picture Box, i have…
2
votes
0 answers

Can't understand a Resharper warning "Possible System.InvalidOperationException"

I got this code: //Group by week if (datarows.All(row => row.Date!= null)) { List> groupByWeek = datarows.GroupBy(row => row.Week.ToString() + row.Date.Value.Year.ToString()) …
L. Schmidt
  • 31
  • 3
2
votes
1 answer

InvalidOperationException when executing SqlCommand with transaction

I have this code, running parallel in two separate threads. It works fine for a few times, but at some random point it throws InvalidOperationException: The transaction is either not associated with the current connection or has been completed. At…
2
votes
2 answers

Why am I getting a "no data is present" error after passing the "HasRows" test?

I've got this code: Protected Function GetArgValsForCompanyName(coName As String) As String() Dim args(2) As String Dim sqlConnection1 As New SqlConnection("SERVER=PLATYPUS42;DATABASE=duckbilldata;UID=durante;PWD=pondscum") Dim cmd As…
B. Clay Shannon-B. Crow Raven
  • 8,547
  • 144
  • 472
  • 862
2
votes
3 answers

C# - BackgroundWorker Constantly Updating Control: Error!

I traditionally have a lot of trouble with BackgroundWorkers in C# for some reason; their concept really seems to stump me, so I'm hoping this is a fairly basic issue and something the can be corrected easily enough... I have two forms that use .NET…
JToland
  • 3,630
  • 12
  • 49
  • 70
2
votes
0 answers

Saving or accepting changes failed because more than one entity of type 'Daily_Services' have the same primary key value

When I try to save this entire nested Object with the red marked object. However, it works well excluding the red marked object. If I add red marked object then through the 'System.InvalidOperationException was caught' exception. then the following…
2
votes
1 answer

C# - Xamarin - HttpClient - Operation is not valid due to the current state of the object - iOS

I'm working on a cross platform library that makes HTTP requests. It's working fine on Android, but when I try to use it on iOS I'm getting an exception and I can't figure out how to fix it. Here is my code: // method from cross platform…
2
votes
1 answer

Why does this error not get caught?

I have the following code in my project, deleteselector is a form that has a datagridview (with autosize columns) on it. try { if (deleteSelector.ShowDialog() == DialogResult.OK) { } } catch (InvalidOperationException) { //Bug…
willem
  • 2,617
  • 5
  • 26
  • 38
2
votes
0 answers

C# .NET WebService WSDL error CS0030: Cannot convert type 'string' to 'ArrayOfString'

I have a WSDL containing an array of strings. The definition looks like:
moik
  • 165
  • 5
  • 14
2
votes
2 answers

Parallel.ForEach loop is performing like a serial loop

I've spent about 8+ hours searching online for help and I couldn't find anything so, here goes. I'm working with Team Foundation Server and C# and I'm trying to acquire a list of work items and convert them into a generic object we made to be bound…
2
votes
0 answers

mult thread reading and writing in same socket c#

PS: sorry my English I can understand but i'm not so good to write. corrections are very welcome First of all, I read some answers here and already know my problem... Well I'm here because I'll need to make some pained changes into my server if…
2
votes
2 answers

"The specified type was not recognized" exception when trying to invoke a webservice call

I'm trying to call a third party webservice using WSE 3.0 as a client in Visual Studio 2005. The call works fine and I can see that I get a good response (I have tracing enabled), but apparently the xml parser chokes over it. I always get an…
2
votes
1 answer

C# Find out what column caused the Sql Exception

I'm getting an exception from SQL Data Reader (MS SQL as datastore) and I'd like to know which column name causes this Exception to be thrown. But I cannot find it in the InnerException..…
theSpyCry
  • 12,073
  • 28
  • 96
  • 152