473,785 Members | 2,720 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(im gByte.Length);
memStream.Write (imgByte, 0 , imgByte.Length) ;
System.Drawing. Image.FromStrea m(memStream);

the error happen at Image.FromStrea m() 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 1658
Peter <Pe***@discussi ons.microsoft.c om> 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(im gByte.Length);
memStream.Write (imgByte, 0 , imgByte.Length) ;
System.Drawing. Image.FromStrea m(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.FromStrea m - you're asking it to read from a
stream which is already at the end at the moment.

--
Jon Skeet - <sk***@pobox.co m>
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***@discussi ons.microsoft.c om> 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(im gByte.Length);
memStream.Write (imgByte, 0 , imgByte.Length) ;
System.Drawing. Image.FromStrea m(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.FromStrea m - you're asking it to read from a
stream which is already at the end at the moment.

--
Jon Skeet - <sk***@pobox.co m>
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***@discussi ons.microsoft.c om> 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.co m>
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
3588
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 be iterated. Here is the code: XmlNodeList nodes = _Document.SelectNodes(myXpathQuery); foreach(XmlNode n in nodes) { ... }
3
248
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 test machine (window 2003 server) I get error: Argument Exception Invalid parameter used" The code that causes the error is: byte imgbyte;
1
17048
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 control in my aspx page with two image buttons, one for an edit command, another a delete command. Here is a cut down code fragment. ...
15
2339
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 Block. To see this create a simple application with two forms. Form 1 should have one button. The code is follows. Run this in the IDE and observe the error and then compare that behavior to what happens when you run the built EXE. Has...
3
2251
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 + "&ChartType=" + drpChartType.SelectedItem.Value.ToLower() + "&Print=" + printVersion.ToString() ... Catch e As Exception
5
1669
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 to Page_Error. I need the call stack of the exception that got me to this point. How can I get
3
3407
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 exception constructors? I've noticed that, f.ex., ArgumentException accepts null arguments without raising ArgumentNullException. Obviously, if nothing is to be supplied to the exception constructor, the default constructor should
11
7036
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, Outlook's MailItem.SaveAs method can return an error message of "The operation failed", but I have no idea what that means. As a test, I tried SaveAs using a filename that contained illegal characters and got the error message "Internal Application...
6
4398
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 restart my application, sometimes several times a day The customer has XP Home SP2
0
9643
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10147
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9947
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8971
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6737
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4046
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2877
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.