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

Connection pool – one process – many threads

My understanding of the connection pool is; if the connectionstring is the exact same, then we reuse the connection instead of make a new connection. My problem is that I’m creating many threads for parallel processing. In this “dummy” program, I…
3
votes
0 answers

Unit testing ControllerFactory.CreateController : This method cannot be called during the application's pre-start initialization phase

I have a test class . And inside this , i have a private class class ControllerProxy : MarshalByRefObject { public IController CreateController() { } } Inside CreateController(), I have created a Mock RequestContext…
DfrDkn
  • 1,270
  • 2
  • 16
  • 23
3
votes
2 answers

DisplayForModel with view name parameter error

My display template "PlanAlternate": @model MyPlan

@Model.Plan.Name

@foreach (var benefit in Model.Plan.Benefits) {
3
votes
2 answers

How to remove entity from session when error on Save and the auto-increment Id has not been generated

NHibernate version: 3.3.2. I have a NHibernate transaction with several operations. As one of the intermediate steps in the transaction, I try to insert a new entity instance with an auto-increment PK via Session.Save. In some cases there is an…
Diana
  • 2,186
  • 1
  • 20
  • 31
3
votes
1 answer

Converting resources file to resx - not serializable

I have a task where I'm reconstructing some source we lost for many projects. For the most, it's gone just fine, but of course on the very last project, I ran into an error that I cannot find any solution to. I used Reflector 8.1 to decompile the…
Tyler Wilson
  • 586
  • 5
  • 11
3
votes
1 answer

Use of NativeWindow for ComboBox causes exception in Dispose-method

In C# Windows.Forms I want to intercept the paste-windowmessage for a combobox. As this doesn't work by overriding the WndProc-method of the combobox, because I would need to override the WndProc of the textbox inside the combobox, I decided to…
user1225775
  • 253
  • 5
  • 14
3
votes
1 answer

Thread cannot access the object

I declared a field: WriteableBitmap colorBitmap; Then I created a simple thread which does something: private void doSomething() { // ... bla bla bla colorBitmap = new WriteableBitmap(/* parameters */); myImage.Source = colorBitmap; //…
Nickon
  • 9,652
  • 12
  • 64
  • 119
2
votes
1 answer

System.InvalidOperationException: Nullable object must have a value. Linq to sql

I am getting this error in one of my development machine. This error is not happening in other machine which is pointing to same database. Definitely both servers are not identical. I don't know what software which is missing in one server cause…
2
votes
1 answer

C# GDI+ SetMapMode

I seem to be having some problems with implementing SetMapMode in C#. Not an expert in C# so Im not too surprised that im seeing errors. Even thought the compilation is fine DrawLine throws InvalidOperationException. Any ideas…
nixgadget
  • 6,983
  • 16
  • 70
  • 103
2
votes
1 answer

System.InvalidOperationException: The instance of entity type cannot be tracked because another instance with the same key value for {'Id'} is already

I have an Api deployed on Azure in which I have a CrCart entity. I want to make sure that if there is already a cart associated with a user and a customer with the status "Saved" you can't add more with that status. The issue here is that I make…
2
votes
2 answers

WCF InvalidOperationException when calling back in a callback

I have a service like this: [ServiceContract(SessionMode = SessionMode.Required, CallbackContract=typeof(IMyServiceCallback))] public interface IMyService { [OperationContract] bool CallService(); } public interface IMyServiceCallback { …
MrNick
  • 399
  • 2
  • 8
  • 16
2
votes
1 answer

Can a C# attribute be serialized into JSON?

I've made a class from the Attribute type public class DemoAttribute : Attribute { [JsonIgnore(Condition = JsonIgnoreCondition.WhenWritingDefault)] public string Label { get; private set; } public DemoAttribute(string label = null)…
Robert H
  • 23
  • 1
  • 4
2
votes
1 answer

Linq to CRM - Invalid operation exception

I'm using a LINQ to CRM from Advanced Developer Extension for MS CRM 4.0. It works fine with direct queries. But I've got a problem when query looks like this: var connectionString = @"User ID=u; Password=p; Authentication Type=AD;…
krlm
  • 817
  • 7
  • 18
2
votes
1 answer

InvalidOperationException when running process with Specflow

I get this when I run my Specflow test: [xUnit.net 00:00:06.30] System.AggregateException : One or more errors occurred. (Cannot mix synchronous and asynchronous operation on process stream.) [xUnit.net 00:00:06.30] ----…
runnerpaul
  • 5,942
  • 8
  • 49
  • 118
2
votes
3 answers

C# System.InvalidOperationException: Collection was modified; enumeration operation may not execute

I have researched this issue and haven't found what pertains to me yet. I am not trying to edit something I am looping through. ************** Exception Text ************** System.InvalidOperationException: Collection was modified; enumeration…
Brandon
  • 1,735
  • 2
  • 22
  • 37