Argument exception Urgent

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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
 
Peter said:
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.
 
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 said:
Peter said:
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.
 
Peter said:
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.
 
Back
Top