PC Review


Reply
Thread Tools Rate Thread

Bitmap BUG in SP2 for CF 1.0??

 
 
PeterB
Guest
Posts: n/a
 
      25th Sep 2003
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


 
Reply With Quote
 
 
 
 
PeterB
Guest
Posts: n/a
 
      25th Sep 2003
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



"Floris Briolas" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> 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]
>
>
>



 
Reply With Quote
 
Alex Feinman [MVP]
Guest
Posts: n/a
 
      25th Sep 2003
This project seems to work fine on the iPaq (SA1100) with SP2. On what
hardware were you seeing a problem?

"Floris Briolas" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
> 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]
>
>
>



 
Reply With Quote
 
PeterB
Guest
Posts: n/a
 
      29th Sep 2003
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 [MVP]" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> This project seems to work fine on the iPaq (SA1100) with SP2. On what
> hardware were you seeing a problem?
>
> "Floris Briolas" <(E-Mail Removed)> wrote in message
> news:%(E-Mail Removed)...
> > 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]
> >
> >
> >

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
'System.Drawing.Bitmap.Bitmap()' Error Fir5tSight Microsoft Dot NET 7 23rd Jun 2006 11:44 AM
copy a portion of a bitmap to another bitmap (via picturebox or other method) ? Mad Scientist Jr Microsoft VB .NET 2 31st Jan 2005 02:26 PM
Extract portion of a bitmap to display, not entire bitmap. Alex Gray Microsoft C# .NET 2 22nd Feb 2004 01:42 PM
Question on how to access bitmap: Public Function getBitmap() As Bitmap Michael Murphy Microsoft VB .NET 2 7th Oct 2003 01:54 PM
extract OLE bitmap from table and save as a bitmap file Brett Rawcliffe Microsoft Access 1 19th Jul 2003 03:42 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 08:14 AM.