Re: Assembly.Load() cause BadImageFormatException
- From: Mattias Sjögren <mattias.dont.want.spam@xxxxxxxx>
- Date: Thu, 29 Dec 2005 14:32:36 +0100
> FileStream fs = new FileStream(fileName, FileMode.Open,
>FileAccess.Read);
> Byte[] body = new Byte[(int)fs.Length];
> fs.Read(buffer, 0, buffer.Length);
There's no guarantee that a single call to Read will fill the byte
array. You should check the return value and if necessary keep calling
Read until everything has been read or the end of the stream is
reached.
>My target is to load an assembly and serialize it for future proposes.
>So I can not use LoadFrom() directly.
But does it load correctly if you use Assembly.LoadFrom(fileName) so
you know that the file isn't corrupt or anything?
Mattias
--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
.
- Follow-Ups:
- References:
- Prev by Date: Assembly serialization
- Next by Date: Re: Assembly.Load() cause BadImageFormatException
- Previous by thread: Re: Assembly.Load() cause BadImageFormatException
- Next by thread: Re: Assembly.Load() cause BadImageFormatException
- Index(es):
Relevant Pages
|