Questions tagged [argumentexception]

An ArgumentException is a specific exception in the .NET framework thrown when one of the arguments provided to a method is not valid.

From MSDN:

ArgumentException is thrown when a method is invoked and at least one of the passed arguments does not meet the parameter specification of the called method.

232 questions
3
votes
3 answers

Should CodeContracts replace the regular ArgumentExceptions?

Could I start using CodeContracts instead of: if (XXX == Y) throw new ArgumentException("bla bla"); How does it work if I develop a library and my library users do not use CodeContracts?
jgauffin
  • 99,844
  • 45
  • 235
  • 372
3
votes
1 answer

How can I get the valid Entries of a ZipArchive when one them contains illegal characters?

I am using System.IO.Compression to extract the content of some Zip files. The problem is that whenever there is an entry with a filename that contains some Windows' illegal characters then an exception is thrown. I have tried several things but I…
3
votes
2 answers

VS 2008 Debugging: System.ArgumentException?

The Problem: I have a forms project which instantiates a class that is defined in a separate dll project. When running the forms application which uses this dll everything runs perfectly fine, however, when I set a breakpoint to inspect objects of…
tbridge
  • 1,754
  • 1
  • 18
  • 35
3
votes
1 answer

Weird exception being thrown when initializing static variable

I recently had a very weird System.ArgumentException. The following code was at my MainWindow constructor on my WPF Application CodeDefinitions.DEFAULT_AVALIABLE = (() => { return true; }); But every time a run the app, this is what I get:…
appa yip yip
  • 1,404
  • 1
  • 17
  • 38
3
votes
0 answers

System.ArgumentException: Value does not fall within the expected range C# when subscribing to event in a different class

I'm developing an Android C# Application using Xamarin. It has a very simple structure: the MainActivity launches and creates instances of classes GUIHandler and Connection. Each class raises different events: In Connection.cs: public…
3
votes
2 answers

C# WPF ArgumentException: Specified Visual is already a child of another Visual or the root of a CompositionTarget

I got a list with Images and their Left/Top locations, that I add to a Canvas. However, I want to be able to add the same Images (same source) to the Canvas, without any problems. When I just use the following code: Image img = ImagesList[i].Image;…
Kevin Cruijssen
  • 9,153
  • 9
  • 61
  • 135
3
votes
4 answers

Windows Forms "System.ArgumentException: Parameter is not valid" from Font.GetHeight(Graphics graphics)

I'm supporting a winforms application using dotnet 3.5 and ComponentFactory Krypton v4.4.0.0, I recently implemented the AppDomain.CurrentDomain.UnhandledException and Application.ThreadException handlers to notify me of exceptions happening on the…
matao
  • 636
  • 3
  • 14
  • 22
3
votes
4 answers

"Parameter is not valid. At System.Drawing.Bitmap..Ctor (Stream stream)."

I am getting the "Parameter is not valid.at System.Drawing.Bitmap..ctor(Stream stream)" in my code. I am using the Following lines in my code, System.Drawing.Bitmap image = new System.Drawing.Bitmap(fileUpload1.PostedFile.InputStream); I don't…
Mahe
  • 2,707
  • 13
  • 50
  • 69
3
votes
0 answers

ArgumentException was thrown on ByteTagVisualization

I'm new to posting on stackoverflow and new to coding for the Microsoft Surface in C# - however I have inherited someone else's code to adapt. I'm getting the following error when trying to set the source for a ByteTagVisualizationDefinition…
2
votes
3 answers

System.ArgumentException and System.ComponentModel.Win32Exception when getting process information

When i try to write process' information to console i get System.ArgumentException and System.ComponentModel.Win32Exception. What causes this? How can i stop having those? Process processListe = Process.GetProcesses(); for (int…
platypus
  • 706
  • 2
  • 18
  • 40
2
votes
0 answers

System.ArgumentException - caption cannot be an empty string

I'm trying to load an existing solution in Visual Studio 2022. One of projects in this solution is in error : A message appears at top of the main window : Visual Studio ran into an uexpected problem with one or more projects. You may need to…
BaptX
  • 561
  • 1
  • 7
  • 21
2
votes
1 answer

DateTime error during time change to daylight saving time

I have to plot a dataset over time which I calculate from a short array. This works but when it comes to converting to the correct time zone it throws an exception: System.ArgumentException: "The supplied DateTime represents an invalid time. For…
2
votes
0 answers

UWP MediaFrameReader - System.ArgumentException: 'Value does not fall within the expected range.'

I am trying to create a UWP application that uses the laptop's webcam to process mediaframes on which I want to search faces using Microsoft Azure Face API. I created a MediaCapture that works well, and a MediaFrameReader, which throws the exception…
pedro
  • 83
  • 1
  • 2
  • 9
2
votes
3 answers

App crashed with error java.lang.IllegalArgumentException: Layout: -72 < 0

I have set the text for the button, But somehow it throws the following exception. I could not able to find the exact reason for getting the below issue. I searched over google and other sources but there is no solution for this. If anyone faced…
2
votes
2 answers

C#: should I throw an ArgumentException or NotSupportedException when an argument type is not supported?

So, I've got a situation where I need to throw an exception because "an argument is not supported". To explain how I got here, this is the rough situation: Ooks come in many types, including Yooks and Zooks Ooks can befriend other Ooks, but only of…
1 2
3
15 16