[Mono-winforms-list] OpenFileDialog throwing ArgumentNullException

Eric Sowell eric.sowell@lexelsoftware.com
Tue, 29 Mar 2005 00:02:03 -0600


The issue is re-created simply by invoking an OpenFileDialog as you did 
in your example. If you run it with the Mono runtime you get the error 
that you posted. However, if I run it with the Microsoft runtime I get a 
different message:

An unhandled exception of type 
'System.Resources.MissingManifestResourceException' occurred in mscorlib.dll

Additional information: Could not find any resources appropriate for the 
specified culture (or the neutral culture) in the given assembly.  Make 
sure "System.Windows.Forms.resources" was correctly embedded or linked 
into assembly "System.Windows.Forms".
baseName: System.Windows.Forms  locationInfo: <null>  resource file 
name: System.Windows.Forms.resources  assembly: System.Windows.Forms, 
Version=0.0.0.0, Culture=neutral, PublicKeyToken=null

I built the project and stepped through the code in Visual Studio and, 
as the stack trace really tells us anyway, in line 1403 of FileDialog 
the code is trying to load an image called "paper" which is in some 
resource file somewhere. The problem is caused because the code can't 
find the resource file/can't load the images, because if you step in to 
the code you'll see at line 400 of ImageList that the list (if you're 
still debugging) has not images in it, and so retrieves a null 
reference. At least, that's what I'm seeing :). And, fyi, if you didn't 
know already, the Managed.Windows.Forms code can be opened, built, and 
worked on inside of Visual Studio. There is a solution file 
(\mono\trunk\mcs\class\Managed.Windows.Forms) ready for you to use. 
You'll have to add a number of files to the project for it to compile 
correctly, but it only takes a couple minutes to find the files. I just 
try to compile and see what blows up, and then add the files it can't find.

So, though the differences could be explained in another way, it seems 
that the error is being thrown by MS's runtime as a 
MissingManifestResourceException but by the Mono runtime it is not, and 
is retrieving a null value without throwing said exception, which then 
causes the ImageList in the FileDialog to throw an exception because it 
is getting a null image reference.

Of course, that isn't the root cause. The root cause is a missing 
resource, it seems. That I just don't know how to fix. Anybody out there 
know that?


Environment:
Running Windows XP
When running Mono runtime, working off of the 1.1.4 installation.
When running using Microsoft's runtime, I'm using the mono SWF library 
instead of the MS, pulled just about an hour ago from svn.


Eric Sowell


Bill Medland wrote:

>On March 28, 2005 04:55 pm, Trimble, Nathan G wrote:
>  
>
>>I realize some people on this list may know the status of various
>>controls at any given moment, but I imagine there are also some lurkers
>>on the list who may just be trying to learn a little bit about mono.
>>I'm pretty decent with C# but not real knowledgeable with mono.  If you
>>could post a little code along with your questions I might be able to
>>try running it too.  Just a thought.
>>    
>>
>
>Well, Since " Test program simply declares an OpenFileDialog" is clearly not 
>explicit enough:
>class ofd01 {
>    public static void Main () {
>        System.Windows.Forms.OpenFileDialog ofd = new 
>System.Windows.Forms.OpenFileDialog();
>        System.Console.WriteLine ("Hello, World");
>    }
>}
>
>  
>
>>Sincerely,
>>
>>
>>Nate Trimble
>>
>>-----Original Message-----
>>From: mono-winforms-list-admin@lists.ximian.com
>>[mailto:mono-winforms-list-admin@lists.ximian.com] On Behalf Of Bill
>>Medland
>>Sent: Monday, March 28, 2005 4:37 PM
>>To: mono-winforms-list@lists.ximian.com
>>Subject: [Mono-winforms-list] OpenFileDialog throwing
>>ArgumentNullException
>>
>>Can anyone tell me, is this me doing something wrong or is it a current
>>bug in the code?
>>
>>(Assuming I am doing the build properly) mono is the current version
>>updated 10 minutes ago.
>>
>>Test program simply declares an OpenFileDialog
>>
>>Program throws:
>>
>>Unhandled Exception: System.ArgumentNullException: Cannot add null image
>>Parameter name: value in <0x00104>
>>System.Windows.Forms.ImageList+ImageCollection:Add
>>(System.Drawing.Image value)
>>in <0x001a6> System.Windows.Forms.MWFFileView:.ctor () in (wrapper
>>remoting-invoke-with-check) System.Windows.Forms.MWFFileView:.ctor
>>()
>>in <0x00236> System.Windows.Forms.FileDialog+FileDialogPanel:.ctor
>>(System.Windows.Forms.FileDialog fileDialog) in (wrapper
>>remoting-invoke-with-check) FileDialogPanel:.ctor
>>(System.Windows.Forms.FileDialog)
>>in <0x000ad> System.Windows.Forms.OpenFileDialog:.ctor () in (wrapper
>>remoting-invoke-with-check) System.Windows.Forms.OpenFileDialog:.ctor ()
>>in <0x00024> ofd01:Main ()
>>
>>--
>>Bill Medland
>>mailto:billmedland@mercuryspeed.com
>>http://webhome.idirect.com/~kbmed
>>
>>_______________________________________________
>>Mono-winforms-list maillist  -  Mono-winforms-list@lists.ximian.com
>>http://lists.ximian.com/mailman/listinfo/mono-winforms-list
>>_______________________________________________
>>Mono-winforms-list maillist  -  Mono-winforms-list@lists.ximian.com
>>http://lists.ximian.com/mailman/listinfo/mono-winforms-list
>>    
>>
>
>  
>