Wayne Barron
asked on
ASP.NET (VB) Specified argument was out of the range of valid values.
Hello all;
OK, It seems there was an update that messed this up, however. I am unsure of when this happened.
I just recently was made aware of it.
Works fine in Windows 10, but not in Win16 Server
This is from an upload script using Uploadify.
Running the site through Visual Studio for testing, and the below is the error code.
Error Code
Errors on this line (Line 120)
When running the site through Google Chrome, and it errors out (IO Error)
I check the Event Viewer on the Server, it gives
Any assistance on this would be great.
Wayne
OK, It seems there was an update that messed this up, however. I am unsure of when this happened.
I just recently was made aware of it.
Works fine in Windows 10, but not in Win16 Server
This is from an upload script using Uploadify.
Running the site through Visual Studio for testing, and the below is the error code.
Error Code
System.ArgumentOutOfRangeException: 'Specified argument was out of the range of valid values.
Parameter name: startIndex'
Errors on this line (Line 120)
ImageToSave.Save(context.Server.MapPath(Path.Combine(thPath, getFile.Insert(getFile.LastIndexOf("."c), ""))), ImageFormat.Jpeg)
When running the site through Google Chrome, and it errors out (IO Error)
I check the Event Viewer on the Server, it gives
Exception information:
Exception type: ArgumentOutOfRangeException
Exception message: Specified argument was out of the range of valid values.
Parameter name: startIndex
at System.String.Insert(Int32startIndex, String value)
at UploadVB.ProcessRequest(HttpContext context) in G:\Inetpub\wwwroot\sitenam e.com\imag es\UploadV B.ashx:lin e 120
at System.Web.HttpApplication.CallHandl erExecutio nStep.Syst em.Web.Htt pApplicati on.IExecut ionStep.Ex ecute()
at System.Web.HttpApplication.ExecuteSt epImpl(IEx ecutionSte p step)
at System.Web.HttpApplication.ExecuteSt ep(IExecut ionStep step, Boolean& completedSynchronously)
Any assistance on this would be great.
Wayne
I expect this is happening because when you look for the last period character it does not exist and so this function is returning -1.
getFile.LastIndexOf("."c)
That is then passed as the index to:
getFile.Insert(getFile.Las tIndexOf(" ."c), "")
Check what the value is of getFile when the error is thrown?
»bp
getFile.LastIndexOf("."c)
That is then passed as the index to:
getFile.Insert(getFile.Las
Check what the value is of getFile when the error is thrown?
»bp
*NO POINTS*
@Nikoloz,
"."c identifies what would normally be defined as a string as a literal CHAR value.
https://docs.microsoft.com/en-us/dotnet/visual-basic/programming-guide/language-features/constants-enums/constant-and-literal-data-types
-saige-
@Nikoloz,
"."c identifies what would normally be defined as a string as a literal CHAR value.
https://docs.microsoft.com/en-us/dotnet/visual-basic/programming-guide/language-features/constants-enums/constant-and-literal-data-types
-saige-
ASKER
Hello all.
From my post.
>>> Works fine in Windows 10, but not in Win16 Server
OK, with that stated.
I can run the same script within Visual Studio and it uploads the file and inserts into the database.
when I run it on Windows 10, it uploads the file and inserts into the database.
On Windows 2016 Server, I get this error.
Any idea's on what to look for?
@bp
>>> Check what the value is of getFile when the error is thrown?
How would I check this??
From my post.
>>> Works fine in Windows 10, but not in Win16 Server
OK, with that stated.
I can run the same script within Visual Studio and it uploads the file and inserts into the database.
when I run it on Windows 10, it uploads the file and inserts into the database.
On Windows 2016 Server, I get this error.
Any idea's on what to look for?
@bp
>>> Check what the value is of getFile when the error is thrown?
How would I check this??
Can you check saving path full length? Maybe because of path maxlength limitation? 247 symbols, as I remember
How would I check this??
You mentioned that you had run it through Visual Studio, so just do that and set a breakpoint on that line and when you get to it examine the variable value.
»bp
ASKER
bp
It works through VS.
It works through VS.
I'm confused, in your original post you mentioned the following, is that no longer the case?
»bp
Running the site through Visual Studio for testing, and the below is the error code.
Error Code
System.ArgumentOutOfRangeException: 'Specified argument was out of the range of valid values.
Parameter name: startIndex'
»bp
ASKER
Your absolutely correct BP.
Scratch my last comment.
Scratch my last comment.
ASKER
The issue is this.
The script is running a Flash upload (Uploadify)
So, I cannot see anything passed through it.
The only thing I get from it is an IO Error
The script is running a Flash upload (Uploadify)
So, I cannot see anything passed through it.
The only thing I get from it is an IO Error
Sorry if I keep asking the same stuff over again, just want to understand the best I can.
So this is not a line of code that you have in VS and can see and set a breakpoint on?
ImageToSave.Save(context.S erver.MapP ath(Path.C ombine(thP ath, getFile.Insert(getFile.Las tIndexOf(" ."c), ""))), ImageFormat.Jpeg)
If it is, then when you debug and get to that break you can't display the value of getfile?
»bp
So this is not a line of code that you have in VS and can see and set a breakpoint on?
ImageToSave.Save(context.S
If it is, then when you debug and get to that break you can't display the value of getfile?
»bp
ASKER
This is what I get in Google Chrome.
Failed to load resource: the server responded with a status of 500 (Internal Server Error)
ASKER
Google Chrome Console (Developer Tools)
Is where I get that message I posted above.
I set a breakpoint on that line, but I am not seeing anything on the page except IO error in the Flash.
And then in CONSOLE, I see.
But there is nothing showing in VS.
I know my way around VS, but there is still a LOT I don't know how to do.
Debugging, I have not had a lot of experience with, as most of the codes I have written have pretty much worked.
So, any hints or advice on the debugging to get the value to show would be great.
Is where I get that message I posted above.
I set a breakpoint on that line, but I am not seeing anything on the page except IO error in the Flash.
And then in CONSOLE, I see.
Failed to load resource: the server responded with a status of 500 (Internal Server Error)
But there is nothing showing in VS.
I know my way around VS, but there is still a LOT I don't know how to do.
Debugging, I have not had a lot of experience with, as most of the codes I have written have pretty much worked.
So, any hints or advice on the debugging to get the value to show would be great.
Do you know what this is trying to accomplish? Without knowing the application I'd interpret it as "take the string getFile, locate the rightmost period in it, and insert nothing there". That doesn't make a lot of sense to me unless it's some sort of a trick I am not aware of, which is certainly possible.
getFile.Insert(getFile.Las tIndexOf(" ."c), ""))
»bp
getFile.Insert(getFile.Las
»bp
ASKER
Here is the script for this part.
What it does is creates the image for the specified file SIZE.
Also would like to mention, this script is over 4 years old.
I have been using it on different sites for this time.
It has worked in all systems it has been on.
Win2k3, WinXP, Win10, Win2016
I am really not sure WHEN it stopped working, as I had not used my sites since I started hosting in-house about 6-months ago, and everything worked then.
Now, I was made aware that it is not working on a customers site the other day.
I tested it in the 2016 server and got the errors.
Tested it on Win10, and it worked like expected.
So, I am at a crossfire on this one.
What it does is creates the image for the specified file SIZE.
Dim pos As Integer = clear.LastIndexOf(".")
Dim ImageToSave As System.Drawing.Image = resizeImage(System.Drawing.Image.FromStream(postedFile.InputStream), New Size(130,110))
ImageToSave.Save(context.Server.MapPath(Path.Combine(thPath, getFile.Insert(getFile.LastIndexOf("."c), ""))), ImageFormat.Jpeg)
Also would like to mention, this script is over 4 years old.
I have been using it on different sites for this time.
It has worked in all systems it has been on.
Win2k3, WinXP, Win10, Win2016
I am really not sure WHEN it stopped working, as I had not used my sites since I started hosting in-house about 6-months ago, and everything worked then.
Now, I was made aware that it is not working on a customers site the other day.
I tested it in the 2016 server and got the errors.
Tested it on Win10, and it worked like expected.
So, I am at a crossfire on this one.
In order to make it work, I would do something like this:
Dim pos As Integer = clear.LastIndexOf(".")
Dim periodPosition As Integer = getFile.LastIndexOf("."c)
Dim ImageToSave As System.Drawing.Image = resizeImage(System.Drawing.Image.FromStream(postedFile.InputStream), New Size(130,110))
ImageToSave.Save(context.Server.MapPath(Path.Combine(thPath, If(periodPosition <> -1, getFile.Insert(periodPosition, ""), ""))), ImageFormat.Jpeg)
-saige-
Given that I see no purpose for:
then perhaps you just remove it, as in:
»bp
getFile.Insert(getFile.Las tIndexOf(" ."c), "")
then perhaps you just remove it, as in:
ImageToSave.Save(context.S erver.MapP ath(Path.C ombine(thP ath, getFile)), ImageFormat.Jpeg)
»bp
ASKER
@Bill, and @-saige-
I did as you both suggested, and this is the error I received.
It has to have everything in order for it to work.
I am really unsure what happened, I am at a complete loss.
I did as you both suggested, and this is the error I received.
System.ArgumentNullException: 'Value cannot be null.
Parameter name: path1'
It has to have everything in order for it to work.
I am really unsure what happened, I am at a complete loss.
It might be helpful if we could see all the code, not just these few lines.
»bp
»bp
ASKER
Hey, bp.
I have a demo of it, let me make sure I can make it reproduce this error and I will send you both over a link to download.
I have a demo of it, let me make sure I can make it reproduce this error and I will send you both over a link to download.
Okay.
ASKER
OK. Here is a link to the demo project.
This is what I use for people to download the source from.
This works in Visual Studio & Windows 10 but NOT in Windows 2016 Server
https://www.cffcs.com/Tutorials/carrzkiss/22/upload/scripts.zip
This is what I use for people to download the source from.
This works in Visual Studio & Windows 10 but NOT in Windows 2016 Server
https://www.cffcs.com/Tutorials/carrzkiss/22/upload/scripts.zip
ASKER
FIXED!!!!!!!!!!
Have to give permission to the folder
Once this is set, the script works.
Wonder what changed, but that fixes it.
Have to give permission to the folder
AUTHENTICATED USERS
Once this is set, the script works.
Wonder what changed, but that fixes it.
Excellent, glad you were able to track that down!
»bp
»bp
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I created an Article on our Knowledge Base for this as well.
Giving Instructions on how to properly add in the permissions for those that may now know the proper procedure.
https://www.cffkb.com/Main.asp?irid=218&Type=Article
Wayne
Giving Instructions on how to properly add in the permissions for those that may now know the proper procedure.
https://www.cffkb.com/Main.asp?irid=218&Type=Article
Wayne
Open in new window