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

Strange behaviour of the ImageList that throws ArgumentException

I'm so confused when I'm using ImageList in .NET. First of all I have a global object (ImageManager) that contains three different ImageLists: smallImages (size: 16x16) - contains 50 images (added from Designer) largeImages (size: 48x48) - contains…
Nexor
  • 103
  • 7
2
votes
1 answer

Why does XName.Get throw an ArgumentException instead of an XmlException for names starting with '{'?

I've been doing some testing of XML in .NET, and discovered that a lot of valid name characters are not allowed. In almost all cases, I get an XmlException on seemingly valid characters. The XmlException is thrown from System.Xml.dll, with this…
yoozer8
  • 7,361
  • 7
  • 58
  • 93
2
votes
1 answer

If Validation methods should return a validation result, why there is ArgumentException class?

I am a bit confused. What MSDN says for ArgumentException is: "The exception that is thrown when one of the arguments provided to a method is not valid." So I would throw an exception if the passed arguments to my method are not valid. But also…
pencilCake
  • 51,323
  • 85
  • 226
  • 363
2
votes
1 answer

Code with DrawImage works locally but fails in Azure with an ArgumentException

i have the following code extracted from my source which is relevant for this: using (Bitmap spriteBitmap = new Bitmap(Width, Height, PixelFormat.Format32bppArgb)) { using (Graphics spriteGraphics = Graphics.FromImage(spriteBitmap)) …
HeManNew
  • 233
  • 2
  • 10
2
votes
3 answers

Errors with Foreach Loop through a List

I have the following piece of code that is giving me problems and I would appreciate any help: private static string CreateOptionString(List Options) { StringBuilder returnValue = new StringBuilder(); foreach (VehicleOption…
jkruer01
  • 2,175
  • 4
  • 32
  • 57
1
vote
1 answer

Why are commas not allowed in a username when using the SqlMembershipProvider?

Although NOT documented as a part of the CreateUser method on MSDN, the SqlMembershipProvider throws an ArgumentException if you try to do anything with a username containing a comma (including trying to create a user). Commas in passwords appear to…
1
vote
1 answer

“System.ArgumentException: Value does not fall within the expected range” when executing LINQ to sharepoint query

var updateItem = (from item in ctx.LI_MyList where item.Id == 1 select item).First(); I got the following exception when executing the query: System.ArgumentException: Value does not fall within the…
Mosbah
  • 1,347
  • 1
  • 14
  • 28
1
vote
1 answer

Why is ProgressBar.SetValue throwing ArgumentException with valid values?

I am using WPF's ProgressBar object, which has a Value property, and I can pass it a constant int or decimal value and it doesn't complain, but if I pass it a float (or int or string) variable value, it barfs an ArgumentException (e.g.…
Dronz
  • 1,970
  • 4
  • 27
  • 50
1
vote
3 answers

ArgumentException Occurred: Parameter is not valid

I have this code snippet (see below) that I'm working with. I keep getting the above error. Can anyone tell me what I'm doing wrong and how to solve it? Thanks. private static Image GetImageFromIPCam(string sourceURL) { byte[] buffer…
ck22
  • 41
  • 8
1
vote
0 answers

UnityStandaloneFileBrowser: ArgumentException Mono.WebBrowser is referenced by System.Windows.Forms

I imported the UnityStandaloneFileBrowser asset to a sample project to test it. Unfortunately I am not able to build the project for Windows. I needed to set the Scripting Backend to IL2CPP and tried to use .NET Standard 2.0 and .NET 4.X, but both…
IWOS
  • 77
  • 6
1
vote
1 answer

System.ArgumentException when trying to use DataGridViewComboBox and ValueMember

ModelLinkControl modelLinkControl = new ModelLinkControl(); modelLinkControl.bindingSourceCModels.DataSource = cModels; modelLinkControl.bindingSourceAModels.DataSource = aModels; modelLinkControl.bindingSourceModelLinks.DataSource =…
1
vote
2 answers

JsonUtility.FromJson keeps throwing ArgumentException

I am trying to receive data from my backend in my unity project, the data looks like this: {"subjectid":98,"name":"test23","first_name":"test23","date_of_birth":"1998-02-16","age":23} I am using the following line to get the data into an…
1
vote
1 answer

Powershell handle variable with special character (open bracket)

I have a script where two variables are compared, it can happen that a variable contains open brackets without closing, like in the example. Then a System.ArgumentException occur: "...not enough closing brackets.." $test1="Testtext" $test2="Testtext…
1
vote
1 answer

ArgumentException: Object of type cannot be converted. But I have an implicit operator C#

I'm trying to make a generic Mediator system, and want to allow messages with implicit operators to receive messages even if their respective type T is not provided. This is where things are breaking, and I don't understand. Hoping someone smarter…
1
vote
1 answer

EF6 Passing Connection String to DbContext: System.ArgumentException: 'Keyword not supported: 'provider'.'

I'm trying to pass a connection string to DbContext class through it's constructor but I keep getting this exception. System.ArgumentException: 'Keyword not supported: 'provider'.' Based on other stackoverflow posts I'm getting the connection…