problems working with gif's in an resx file

  • Thread starter carl engerer via DotNetMonster.com
  • Start date
C

carl engerer via DotNetMonster.com

Hi,

I am getting a problem when debugging an application to my pocketpc device on
VS2005, every time there is a call to get a recource below:

base.Image = (Bitmap)global::MyApp.Properties.Resources.ResourceManager.
GetObject("imageName");



I get the following error(s) in output..

A first chance exception of type 'System.IO.FileNotFoundException' occurred
in mscorlib.dll

A first chance exception of type 'System.IO.FileNotFoundException' occurred
in mscorlib.dll

A first chance exception of type 'System.UnauthorizedAccessException'
occurred in mscorlib.dll


I have read a post which was about a similar problem but it wasnt helpful,
this also affects the application when running without debugging as the
'Unauth' exceptions are really slowing the app down. I have also tested the
application by loading the gif files from a directory but then I am getting
an 'Invalidcast' exceptions! this is getting on my nerves, can anyone help??
 
K

Kent

Boy, does that look familiar. I'm having the same problem in code targeted
at a WinCE 5.0 device using VS2005. I'm trying to access my resources (jpg,
icons) using the method shown in this article:
http://msdn.microsoft.com/msdnmag/issues/06/00/SmartClients/default.aspx.
And I get the same errors. The program runs in spite of this (and does load
and properly display the images) but I'd like to understand what I'm doing
wrong to cause these exceptions.

The code I'm using is similar to the article:

Image myImage = Properties.Resources.myJpg;

Any suggestions? Thanks
 
N

n33470

I can't speak to the examples you are using, but I have a bitmap file
(.bmp) in my project that I reference from the resource file. Here is
a snippet of my code:

Assembly asm = Assembly.GetExecutingAssembly();
Stream bitmapStream =
asm.GetManifestResourceStream("KMB.UI.PPC.kds.bmp");
Bitmap bmpSplash = new Bitmap(bitmapStream);
pictureBox1.Image = bmpSplash;


The file "kds.bmp" is in the project named "KMB.UI.PPC", which is also
the executing assembly that I'm running. The build action on the file
is set to "embedded resource".

HTH,

--steve
 
C

carl engerer via DotNetMonster.com

The example you have given is what I have used also, why I cant use the
recourcemanager I dont know..but yes thanks for the replies guys, n33470 your
example is good.
I can't speak to the examples you are using, but I have a bitmap file
(.bmp) in my project that I reference from the resource file. Here is
a snippet of my code:

Assembly asm = Assembly.GetExecutingAssembly();
Stream bitmapStream =
asm.GetManifestResourceStream("KMB.UI.PPC.kds.bmp");
Bitmap bmpSplash = new Bitmap(bitmapStream);
pictureBox1.Image = bmpSplash;

The file "kds.bmp" is in the project named "KMB.UI.PPC", which is also
the executing assembly that I'm running. The build action on the file
is set to "embedded resource".

HTH,

--steve
Boy, does that look familiar. I'm having the same problem in code targeted
at a WinCE 5.0 device using VS2005. I'm trying to access my resources (jpg,
[quoted text clipped - 40 lines]
 

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