Problems with loading images from Resource in CF 2.0 (Target platform: Windows Mobile 5.0 SDK)

C

Carsten Marx

Hello,

i've the follwoing scenario:

Visual Studio 2005 prof.
Windows Mobile 5.0 SDK installed
Pocket PC Dell Axim X51v with CF 2.0
Target Platform is Windows Mobile 5.0

I've created a standard resource via the project properties and added
some resources (icon, png,...)

I'm trying to use the resources in that way:

this.Icon = Resources.Icon; (where Icon is a resource object with the
type Icon)
this.logo.Image = (Image)Resources.Logo; (where Logo isa png-File which
is imported as resource)

If i deploy the project i get the following:

System.NotSupportedException was unhandled
Message="System.Drawing.Icon"
StackTrace:
bei System.Resources.ResourceReader.LoadObjectV2()
bei System.Resources.ResourceReader.LoadObject()
bei System.Resources.RuntimeResourceSet.GetObject()
bei System.Resources.ResourceManager.GetObject()
bei Test.Properties.Resources.get_Icon()
bei Test.Start..ctor()
bei Test.Start.Main()

If i try to debug the project i get the message:

Error 1 The "GenerateResource" task failed unexpectedly.
System.InvalidOperationException: Collection was modified; enumeration
operation may not execute.
at
Microsoft.Build.Shared.ExceptionHandling.RethrowUnlessFileIO(Exception
e)
at Microsoft.Build.Tasks.GenerateResource.NeedSeparateAppDomain()
at Microsoft.Build.Tasks.GenerateResource.Execute()
at Microsoft.Build.BuildEngine.TaskEngine.ExecuteTask(ExecutionMode
howToExecuteTask, Hashtable projectItemsAvailableToTask,
BuildPropertyGroup projectPropertiesAvailableToTask, Boolean&
taskClassWasFound) Test



What's wrong here? Any hint for me?
Thanks in advance...



Best regards

Carsten Marx


P.S.: The project was ported from CF 1 to CF 2.
 
G

Ginny Caughey [MVP]

Carsten,

I'm using code like this, which came from the MSDN SignatureControl sample
at
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnnetcomp/html/PPCSignatureApp.asp:

static public Bitmap LoadImage(string imageName)
{
return new
Bitmap(System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("MyApp.Images."
+ imageName));
}

For this to work, Images is a folder off the MyApp project folder, and
imageName is the name of the image file with the Build Action property set
to Embedded Resource.
 

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