[Mono-dev] Mono reflection seems a bit broken.

PFJ pjohnson1 at uclan.ac.uk
Tue Feb 9 06:51:46 EST 2010


Hi,

This code works fine under .NET 3.5 but dies miserably with Mono 2.6.1

using System;
using System.Reflection;
using System.IO;
using System.Drawing;
using System.Windows.Forms;
using System.Xml;
using System.Resources;

amespace molarity
{
	/// <summary>
	/// Description of periodic.
	/// </summary>
	public partial class periodic : Form
	{
		public periodic()
		{
			//
			// The InitializeComponent() call is required for Windows Forms designer
support.
			//
			InitializeComponent();
			
			//
			// TODO: Add constructor code after the InitializeComponent() call.
			//
			
		}

		/* load the element from the xml file using xmlhander */

		void displaytheelement(object sender, EventArgs e)
		{
			int m = ((Label)sender).TabIndex - 1;
			xmlhandler xml = new xmlhandler();
			xml.dotheread(m);
			es.Text = xml.element_structure;
			atmass.Text = xml.element_weight.ToString();
			atno.Text = xml.element_number.ToString();
			name.Text = xml.element_name;
			symbol.Text = xml.element_symbol;
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
            try
            {
                Stream resourceStream =
executingAssembly.GetManifestResourceStream(xml.picname);
                pictureBox1.Image = new Bitmap(resourceStream);
            }
            catch (System.ArgumentException)
            {
                MessageBox.Show("Unable to find element picture", "Picture
not found", MessageBoxButtons.OK);
            }
		}
		
	}
}

The resources are set to be embedded into the binary. I run the executable
this comes from and it does what it should (the displaytheelement method
gets the information for the data (stored in xmlhandler xml), then uses
reflector to grab the embedded image and display in pictureBox1. If the
picture isn't found, the message box appears but the application doesn't
fall over dead.

Under Mono 2.6.1, it doesn't matter which element I click, I always get the
message box and the application quits with no throwback. Under .NET, I click
on the element, the information appears, the picture appears and if the
picture isn't there, the message box appears, but then the application
continues.

Is the code wrong or am I?

I can upload the full source if it will help identify a bug.

TTFN

Paul
-- 
View this message in context: http://old.nabble.com/Mono-reflection-seems-a-bit-broken.-tp27514082p27514082.html
Sent from the Mono - Dev mailing list archive at Nabble.com.



More information about the Mono-devel-list mailing list