473,396 Members | 1,804 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Argument exception Urgent

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
3 1610
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Sébastien Ros | last post by:
During the process of an XML document, I have to make a SelectNodes() call on an XmlDocument. It returns an isntance of XPathNodeList. I can call it several times but at one point, the result can't...
3
by: Peter | last post by:
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...
1
by: Timbo | last post by:
Hi all, This is my first message here so i'll try and include all the information that will help you help me out, if possible. Basically I am using C# in ASP.NET 2.0 and have a Repeater...
15
by: Mark Lewis | last post by:
I have a weird error trapping problem. When running the IDE everything works fine but not when running in an EXE I get the Unhandled Exception Error message box intead of the one in my Try....Catch...
3
by: c676228 | last post by:
Hi everyone, I have a piece of code in sales.aspx.vb like this: Protected WithEvents Message As System.Web.UI.WebControls.Label Try ... ChartImage.ImageUrl = "ChartGenerator.aspx?" + DataStr +...
5
by: David Thielen | last post by:
Hi; I have added the code to my code behinds of: private void Page_Error(object sender, EventArgs e) { throw Server.GetLastError(); } But I now have the problem that the call stack I get is...
3
by: matko | last post by:
This is a long one, so I'll summarize: 1. What are your opinions on raising an exception within the constructor of a (custom) exception? 2. How do -you- validate arguments in your own...
11
by: Don | last post by:
When using Visual Basic .NET with a reference to Interop.Outlook, is there a way to get more detailed information about an error other than Exception.Message or Exception.ToString? For example,...
6
by: Steve | last post by:
Hi All I have a windows forms Application (SAM) in vb.net 2008 using .net framework V2 One and only one customer out of 30 customers is getting errors daily where they have to close and...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.