argumentexception

SaveFileDialog exception in my WPF app

不羁岁月 提交于 2019-12-10 17:21:57
问题 One of my customers is experiencing a crash in my WPF application when saving a file. My save file code is: var saveFileDialog = new SaveFileDialog { InitialDirectory = string.Concat(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), @"\MyApp"), FileName = "MyFile", OverwritePrompt = true, AddExtension = true }; if (saveFileDialog.ShowDialog() == true) { ... } And here is the exception they are getting: Value does not fall within the expected range. A System.ArgumentException

App Doesn't Crash While Debugging, but Does When Running Normally

淺唱寂寞╮ 提交于 2019-12-09 18:25:42
问题 System Information Windows 10 Technical Preview (build 9926) Visual Studio Community 2013 Attempting to debug on: [AT&T] Lumia 635 (Windows 10 Technical Preview for phones build 9941 w/ Lumia Cyan) [AT&T] Lumia 1520 (Windows Phone 8.1 with Lumia Denim and PfD) [Unlocked] BLU Win Jr (Windows Phone 8.1 with PfD) [Verizon] Lumia Icon (Windows Phone 8.1 with Lumia Denim and PfD) I trying to get location services working in my app. Previously, I had Visual Studio throw the error. It was an

Font 'Times New Roman' does not support style 'Regular'

放肆的年华 提交于 2019-12-08 16:15:49
问题 Anybody hear of this one? System.ArgumentException: Font 'Times New Roman' does not support style 'Regular'. I've got a WinForms app that is deployed via ClickOnce. For some reason a number of users are getting this error. I can see getting this error because of picking a non-standard font, but Times New Roman, Regular? Is there a service pack or something that people need? I would love to hear from anybody that has figured out a solution to this problem. 回答1: One solution that seems to work

Application.Run throws ArgumentException was unhandled

倾然丶 夕夏残阳落幕 提交于 2019-12-08 04:16:05
问题 I have a condition in which I need to close the application and so I call this.Dispose () when I set a certian flag. At first I thought it was a problem of calling functions after I call this.Dispose () and so I moved the code to be the last thing called, but I still get an "ArgumentException was unhandled" "Parameter is not valid." On the Application.Run (new myApp (); line. What am I doing wrong? Did I miss something along the way? Or maybe there is a better way to close the application?

Calling ToList() on ConcurrentDictionary<TKey, TValue> while adding items

橙三吉。 提交于 2019-12-04 02:55:57
问题 I've run into an interesting issue. Knowing that the ConcurrentDictionary<TKey, TValue> is safely enumerable while being modified, with the (in my case) unwanted side-effect of iterating over elements that may disappear or appear multiple times, I decided to create a snapshot myself, using ToList() . Since ConcurrentDictionary<TKey, TValue> also implements ICollection<KeyValuePair<TKey, TValue>> , this causes the List(IEnumerable<T> collection) to be used, which in turn creates an array in

Custom task runner method throws ArgumentException

ε祈祈猫儿з 提交于 2019-12-02 02:55:27
问题 Because of the fact that CultureInfo is not being copied from thread to thread I have made following method to do that thing for me. public static StartCustomTask(Action action, TaskCreationOptions tco = TaskCreationOptions.None) { var currentCult = Thread.CurrentThread.CurrentCuture; var currentUiCult = Thread.CurrentThread.CurrentUICulture; return Task.Factory.StartNew(() => { Thread.CurrentThread.CurrentCuture = currentCult; Thread.CurrentThread.CurrentUICulture = currentUiCult; action();

Custom task runner method throws ArgumentException

时光毁灭记忆、已成空白 提交于 2019-12-01 23:22:41
Because of the fact that CultureInfo is not being copied from thread to thread I have made following method to do that thing for me. public static StartCustomTask(Action action, TaskCreationOptions tco = TaskCreationOptions.None) { var currentCult = Thread.CurrentThread.CurrentCuture; var currentUiCult = Thread.CurrentThread.CurrentUICulture; return Task.Factory.StartNew(() => { Thread.CurrentThread.CurrentCuture = currentCult; Thread.CurrentThread.CurrentUICulture = currentUiCult; action(); }, tco); } basically this code copies culture info from current thread to the thread that is gonna

C# SerialPort#Open() method throws ArgumentException because of port name?

a 夏天 提交于 2019-11-29 17:41:07
On my local machine, Windows XP Ports (COM & LPT) COM3 RIM Virtual Serial Port v2 (COM4) RIM Virtual Serial Port v2 (COM5) the following code, using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO.Ports; using System.Threading; namespace OpenSerialPortTest { class Test { static void Main(string[] args) { foreach (String serialPortName in SerialPort.GetPortNames()) { SerialPort serialPort = new SerialPort(serialPortName); try { serialPort.Open(); // Line 19 Console.WriteLine(serialPort.PortName); } catch (Exception ex1) { Console.WriteLine(ex1);

Empty Path Name Is Not Legal [duplicate]

心不动则不痛 提交于 2019-11-29 11:17:11
This question already has an answer here: empty path name not legal 2 answers So I'm trying to compile an Asteroids game. It's almost working, all the files are in place etc etc... The issue comes when it hits this code. FileStream myFileStream = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.Read); string myTempFile = @"F:\Documents\Junior School\Computer Programming (Java 1)\AsteroidsWithSound\AsteroidsWithSound\temp\mysound" + i.ToString() + ".wav"; It gives me an Error/Warning, not sure exactly what it is called but it says ArgumentException was unhandled. Empty path

Marshal.PtrToStructure throwing System.ArgumentException error

折月煮酒 提交于 2019-11-29 04:03:16
I'm attempting to get a KBDLLHOOKSTRUCT from a keyboard-hook's lParam. private static IntPtr HookCallback(int nCode, IntPtr wParam, IntPtr lParam) { KBDLLHOOKSTRUCT kbd = new KBDLLHOOKSTRUCT(); Marshal.PtrToStructure(lParam, kbd); // Throws System.ArguementException ... Unfortunately the PtrToStructure is throwing two A first chance exception of type 'System.ArgumentException' occurred in myprogram.exe errors every time a key is pressed. It also stops that method in its tracks. MSNDA says: http://msdn.microsoft.com/en-us/library/4ca6d5z7.aspx ArgumentException when: The structureType parameter