invalidoperationexception

What leads to the floating point exception “1.#IO”

≯℡__Kan透↙ 提交于 2019-12-13 02:36:46
问题 I'm debugging a simulation with many calculations in many Fortran files. I am used to seeing some floating point exceptions (-1.#QNB or 1.#QNAN) for errors that involve division by zero or operations that exceed the maximum size for floating point number. I'm assuming -1.#IO means invalid operation, but I'm not sure mathematically what would cause this and not QNB or QNAN or QINF. What would lead to the exception -1.#IO? 回答1: According to the IEEE 754 Standard for Floating Point Operations,

Why can't we change Values of a dictionary while enumerating its keys?

一世执手 提交于 2019-12-12 08:17:43
问题 class Program { static void Main(string[] args) { var dictionary = new Dictionary<string, int>() { {"1", 1}, {"2", 2}, {"3", 3} }; foreach (var s in dictionary.Keys) { // Throws the "Collection was modified exception..." on the next iteration // What's up with that? dictionary[s] = 1; } } } I completely understand why this exception is thrown when enumerating a list- it seems reasonable to expect that during enumeration, the Structure of the enumerated object does not change. However- does

a question about exception in c#

怎甘沉沦 提交于 2019-12-12 06:39:30
问题 following is a code snippet: class xxx { public xxx(){} try { throw new Exception(InvalidoperationException); } catch(Exception x) { } catch(InvalidoperationException x) { } } can anyone tell which exception will raise here and what is the reason behind it. 回答1: Wow, lots of problems here. Where to start? That code won't compile. The try-catch block that you've defined is outside of any method, which is not allowed. You need to move it inside of a method. Never throw a method that you intend

Why won't this Audio play in Windows Phone 7?

馋奶兔 提交于 2019-12-12 03:38:56
问题 I am trying to play audio in my Silverlight for Windows Phone 7 app. I have an MP3 audio file with its build action set to resource. To play the sound, I use: SoundEffectInstance sfi = null; ... Stream source = Application.GetResourceStream(new Uri("/Bird Calls;component/Crow.mp3", UriKind.Relative)).Stream; Microsoft.Xna.Framework.Audio.SoundEffect effect = SoundEffect.FromStream(source); sfi = effect.CreateInstance(); sfi.Play(); This code throws a InvalidOperationException at the

How can I remove more than one item from a listbox?

…衆ロ難τιáo~ 提交于 2019-12-12 03:25:40
问题 This is really getting annoying; or, to be honest, it became quite annoying a good while back. Programmatically removing items from a listbox should be pretty straightforward, yet it seems everything I try ends up the same: with an exception. This time it's "InvalidOperationException". In context (excerpt of log file): Date: 2/12/2015 7:15:17 PM Message: Reached frmMain.UpdateGUIAfterTableSend Date: 2/12/2015 7:15:17 PM Message: From frmMain.SendDeliveries(): InvalidOperationException; Inner

Cross-thread InvalidOperationException while trying to access SerialPort dynamically

血红的双手。 提交于 2019-12-11 14:17:05
问题 I have multiple serial devices connected to my PC and I am working on a program that allows users select as many as ports they want and then the program will dynamically creates TabPage and adds them to TabControl . Each tab page will also have a multiline TextBox that will show the incoming data from the assigned serialport to it. Here is my code that tries to create these controls dynamically: private void AddSerialPort(string portName) { ActiveSerialPorts.Add(portName); if (

InvalidOperationException: dispatcher processing is suspended on ImageOffsetProperty

空扰寡人 提交于 2019-12-11 12:53:56
问题 I am using C# and WPF and am trying to slide an image strip along the screen. I am being honest, I got the code from some code sample on the Internet and took the parts I needed from it. public double ImageOffset { get { try { return (double)this.Dispatcher.Invoke( System.Windows.Threading.DispatcherPriority.Background, (DispatcherOperationCallback)delegate { return GetValue(ImageOffsetProperty); }, ImageOffsetProperty); } catch { return (double)this.GetValue(ImageOffsetProperty); } } set {

MVC InvalidOperationException adding role to user

别来无恙 提交于 2019-12-11 11:29:21
问题 I was following the tutorial on this page, about how to add roles to users programatically in C# MVC. However, when the code executes I get the following error: System.InvalidOperationException was unhandled by user code HResult=-2146233079 Message=UserId not found. Source=Microsoft.AspNet.Identity.Core StackTrace: at Microsoft.AspNet.Identity.UserManager`2.<AddToRoleAsync>d__83.MoveNext() --- End of stack trace from previous location where exception was thrown --- at System.Runtime

Common Language Runtime detected an invalid program error in unit testing

我怕爱的太早我们不能终老 提交于 2019-12-11 09:07:28
问题 I have the following code this.SafeUpdate(rate, Guid.Parse(import.myGuid), c => c.myGuid); SafeUpdate basically takes the parsed guid value and applies it to the myGuid property on the rate object. This works fine from my front end, but throws the "CLR detected..." error when run in a unit test. What's odd is the same statement for DateTime.Parse and int.Parse works fine. It just fails for Guid and decimals. I don't believe the error is with the parsing (it has the correct parsed value when

InvalidOperationException despite MaxJsonLength = Int32.MaxValue

一世执手 提交于 2019-12-11 06:29:12
问题 I don't think I'm exceeding the MaxJsonLength, but I'm still getting "Error during serialization or deserialization using the JSON JavaScriptSerializer. The length of the string exceeds the value set on the maxJsonLength property". I checked to see how long the result is, and it's 25,000 rows. I checked the average length of each row by outputting a smaller result, and the average row is 48.5 characters long. 25,000 * 48.5 characters = 1,224,140 characters. MS says that maxJsonLength is in