By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,743 Members | 1,058 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,743 IT Pros & Developers. It's quick & easy.

Argument exception Urgent

P: n/a
I have asp.net code using C# that will convert tif file into jpg and then it
display them. The program works on my machine and Dev machine with Window XP
professional. When I deploy the program on test machine (window 2003 server)
I get error:

Argument Exception Invalid parameter used"

The code that causes the error is:

byte[] imgbyte;
MemoryStream memStream = new MemoryStream(imgByte.Length);
memStream.Write(imgByte, 0 , imgByte.Length);
System.Drawing.Image.FromStream(memStream);

the error happen at Image.FromStream() method.

I tried different ways and searched google without success. Also, I tried
Image.FromFile() where I got "out of memory exception" error.

Is window 2003 cause of this problem?
How I know if GDI+ is installed on window 2003?
Does the dell generated by visual studio .net include the GDI+ dll?

I would appreciate any help in this matter. Thanks

Any help to resolve the issue
I do not know why it does not work on test machine today. It works on my
machine and it worked on test machine previously. I appreciate any help to
resolve this problem. Thanks

Oct 25 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
Peter <Pe***@discussions.microsoft.com> wrote:
I have asp.net code using C# that will convert tif file into jpg and then it
display them. The program works on my machine and Dev machine with Window XP
professional. When I deploy the program on test machine (window 2003 server)
I get error:

Argument Exception Invalid parameter used"

The code that causes the error is:

byte[] imgbyte;
MemoryStream memStream = new MemoryStream(imgByte.Length);
memStream.Write(imgByte, 0 , imgByte.Length);
System.Drawing.Image.FromStream(memStream);


Well, I'm sure that isn't the whole of the code which causes the error,
as that wouldn't compile.

However, you should really put the position of the stream back to 0
before passing it to Image.FromStream - you're asking it to read from a
stream which is already at the end at the moment.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Oct 25 '05 #2

P: n/a
I am sorry I had put the position back to 0 but I forgot to included in here.
For some reason it seems in window 2003 the byte stream (image) does not
work. I read that there is bug in GDI+ that can not handle 24 and 16 bit tif
files. I have 4bit gray scale tif file. Any idea? Thanks

"Jon Skeet [C# MVP]" wrote:
Peter <Pe***@discussions.microsoft.com> wrote:
I have asp.net code using C# that will convert tif file into jpg and then it
display them. The program works on my machine and Dev machine with Window XP
professional. When I deploy the program on test machine (window 2003 server)
I get error:

Argument Exception Invalid parameter used"

The code that causes the error is:

byte[] imgbyte;
MemoryStream memStream = new MemoryStream(imgByte.Length);
memStream.Write(imgByte, 0 , imgByte.Length);
System.Drawing.Image.FromStream(memStream);


Well, I'm sure that isn't the whole of the code which causes the error,
as that wouldn't compile.

However, you should really put the position of the stream back to 0
before passing it to Image.FromStream - you're asking it to read from a
stream which is already at the end at the moment.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too

Oct 26 '05 #3

P: n/a
Peter <Pe***@discussions.microsoft.com> wrote:
I am sorry I had put the position back to 0 but I forgot to included in here.
That's why short but complete programs are so useful when you're trying
to demonstrate a problem. See
http://www.pobox.com/~skeet/csharp/complete.html
For some reason it seems in window 2003 the byte stream (image) does not
work. I read that there is bug in GDI+ that can not handle 24 and 16 bit tif
files. I have 4bit gray scale tif file. Any idea? Thanks


Does it work with other image formats? If so, that would suggest that
that's the problem.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Oct 26 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.