[Mono-list] Fwd: ilasm2 can't compile vbbyref marshalled parameter

Joe Mason joe at notcharles.ca
Fri Dec 14 22:57:27 EST 2007


On 12/14/07, Sebastien Pouliot <sebastien.pouliot at gmail.com> wrote:
> Hello Joe,
>
> On Fri, 2007-12-14 at 00:48 -0500, Joe Mason wrote:
> > I'm trying to make some small edits to a closed-source VB app to get
> > it running on Linux (the System.Drawing.Image.FromFile "OutOfMemory"
> > problem) by disassembling it with monodis and reassembling it with
> > ilasm2.
>
> Has the problem been filled in bugzilla.ximian.com ? because AFAIK
> there's none in FromFile, unless the file is bad.

As far as I could tell from Googling, the problem is with the .NET
design, rather than mono itself - at least, lots of people are
reporting it for .NET apps they're writing themselves, often in VB,
and I assume most of these use Microsoft's .NET.

The problem is that FromFile throws OutOfMemory on any error condition
(permissions problems, bad image format, etc).  See the following two
posts - the first advises people to use OpenRead and FromStream, and
the second has a huge list of people saying, "I got the same
exception, but my problem was something different!"

http://dotnetjunkies.com/Forums/ShowPost.aspx?PostID=3344
http://jcapka.blogspot.com/2006/06/imagefromfile-gives-out-of-memory.html

I had assumed that Mono's FromFile was just following the Microsoft
behaviour for compatibility, even though it would be better to have it
throw a wider range of errors.

I can't really file a bug until I'm sure why this particular code
causes the exception, though, otherwise I don't have a very repeatable
bug report.

> FromStream can have some issues on Win32 (only) since the way MS deals
> with loading requires the stream to be alive as long as the image.

Thanks, good to know.

(snip errors when pinvoking GetVolumeInformationA)

> Have a look at pinvoke.net

Uh, it just occured to me - will pinvoking this even WORK on Linux,
even if I get it to compile?  I do have Wine installed, so I have a
version of this function somewhere, but getting Mono to find it sounds
like a huge hassle.  Surely .NET has its own equivalent that could be
called natively?

Thanks for the help,
Joe


More information about the Mono-list mailing list