Re: Argument exception Urgent



Peter <Peter@xxxxxxxxxxxxxxxxxxxxxxxxx> 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 - <skeet@xxxxxxxxx>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
.



Relevant Pages

  • Re: ObjectTextToBinary
    ... > window" exception occured at ReadComponentline. ... If you want to load a component with this requirement from a stream it ... Then create an *empty* instance of the form class, ... If you need a way to clone individual components search the newsgroup archives ...
    (borland.public.delphi.language.objectpascal)
  • Re: Viewing family members
    ... the URL to the encoder (or the server for that stream) and you'd be set. ... All e-mail to this account will bounce or be deleted - *use the newsgroups*. ... >>>> You have an uncle who lives in New York city, ... and a window pops up. ...
    (microsoft.public.windowsmedia.player)
  • Re: minor annoyance (Re: large dictionaries)
    ... minorly modified version of deflate (and thus being naturally more generic ... dynamic blocks (32kB window, ... structure (rather than just dumping a raw stream). ... or, I could use the gzip format, but would then produce files not decodable ...
    (comp.compression)
  • Re: Disable Context Menu Item
    ... There is a way to load content from stream, ... the window handle that I'm ... subclassing it didn't work ...
    (microsoft.public.inetsdk.programming.webbrowser_ctl)
  • Re: How to control another program to run cryptically?
    ... LRESULT CALLBACK GetMsgProc(int nCode, WPARAM wParam, LPARAM lParam) ... FILE* stream; ... forcing the window to become invisible. ...
    (microsoft.public.vc.mfc)