Bitmap BUG in SP2 for CF 1.0??

P

PeterB

I know SP2 has been cancelled but I want to highlight this anyway and make
sure it is brought to MS' attention (if it indeed is a bug and not just bad
code from me :))

I have written a small test program which demonstrates the bug. The code is
below and is not very complex.
The whole issue is when I reference a own made .NET System Library dll
(which also is within the solution in my case), and this dll uses the
System.Drawing namespace and I instantiate or use the Bitmap class I recieve
an unhandled System.TypeLoadException.

The code is REALLY simple and works for PPC2002 and PPC2003 without SP2 (but
not with).

THE CODE:

This is the actual test program. It needs a reference to ImgDll (see below).
"myImg" is the instance of the "MyImg" class inside the dll.

using System;
using System.Drawing;
using System.Windows.Forms;
using ImgDll;
namespace TestProj
{
/// <summary>
/// Summary description for Form1.
/// </summary>
public class Form1 : System.Windows.Forms.Form
{
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.Button button1;
static string path = "TestProj.Images.";
Bitmap noPic = null;
MyImage myImg;
public Form1()
{
InitializeComponent();
myImg = new MyImage();
noPic = myImg.Get("noPic");
}
protected override void Dispose( bool disposing )
{
base.Dispose( disposing );
}
#region Windows Form Designer generated code
private void InitializeComponent()
{
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.button1 = new System.Windows.Forms.Button();
//
// pictureBox1
//
this.pictureBox1.Location = new System.Drawing.Point(128, 8);
this.pictureBox1.Size = new System.Drawing.Size(96, 136);
//
// button1
//
this.button1.Location = new System.Drawing.Point(152, 152);
this.button1.Text = "button1";
this.button1.Click += new System.EventHandler(this.button1_Click);
//
// Form1
//
this.Controls.Add(this.button1);
this.Controls.Add(this.pictureBox1);
this.MinimizeBox = false;
this.Text = "Form1";
}
#endregion
static void Main()
{
try
{
Application.Run(new Form1());
}
catch( System.TypeLoadException typeExc )
{
MessageBox.Show(typeExc.Message);
}
}
private void button1_Click(object sender, System.EventArgs e)
{
this.pictureBox1.Image = myImg.Get("e01");
}
}
}


And this is the System Library dll code, you need two images in the
application directory named noPic.gif and e01.gif:

using System;
using System.Reflection;
using System.Drawing;
namespace ImgDll
{
/// <summary>
/// Summary description for Class1.
/// </summary>
public class MyImage
{
Bitmap noPic = null;
static string extension = ".gif";
static string path = "ImgDll.";
public MyImage()
{
noPic = new
Bitmap(Assembly.GetExecutingAssembly().GetManifestResourceStream(path +
"noPic" + extension ));
}
public Bitmap Get( string strImgName )
{
if( strImgName != "" )
{
string[] tmp = strImgName.Split('.');
strImgName = tmp[0];
strImgName = tmp[0].ToLower();
try
{
Bitmap bmp = new Bitmap(Assembly.GetExecutingAssembly().
GetManifestResourceStream(path + strImgName + extension));
return bmp;
}
catch( Exception exc )
{
return noPic;
}
}
return null;
}
}
}

Any comments???

/ Peter
 
P

PeterB

Ah... *blush*

Yes the code works... it works too well ;-) The error isn't there any longer
and I know why now. In my application I used a Class Library project (while
you used a smart device application) for the class/resource dll file. This
means my application used real .NET framework System.Drawing which
apparently worked before the SP2 was added.

Anyway, thanks for the help! I will convert my Class Library to a Smart
Device Application that has OutPutType Class Library ;-) instead. Thanks
again!

/ Peter
 
A

Alex Feinman [MVP]

This project seems to work fine on the iPaq (SA1100) with SP2. On what
hardware were you seeing a problem?
 
P

PeterB

As I wrote in the previous message I realized it was my own fault. The
Windows Library component worked before SP2 but that was probably not
correct and was fixed in SP2, which caused my program to stop working
instead ;-)


Alex Feinman said:
This project seems to work fine on the iPaq (SA1100) with SP2. On what
hardware were you seeing a problem?

Floris Briolas said:
Hi Peter

I'v just de installed sp2 so I could not test it, however I decided to post
my/your code for those who still have the SP2 installed, I have alse
included a small pic since you did not described to do so...

(so it's just dl-unzip-and-run)


[cut]
test my code plz...
[/cut]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top