469,641 Members | 1,187 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,641 developers. It's quick & easy.

problem with pictuerbox

ma
Hello,

I am new in .NET and I am writing my first program in c++/CLI on MSVC
2005.

I add a PictureBox to my form and then using its properties I change its
image property to one image from my hard disk. it generate the following
code for me:

this->image1->Image = (cli::safe_cast<System::Drawing::Image^
(resources->GetObject(L"image1.Image")));


but when I am running my program, it generate an exception with the error
that it couldn't find the specified objects in my resources. I checked the
resource and there is no resource with this name there.

What is wrong with this?

Best regards


Mar 12 '06 #1
5 1635
> but when I am running my program, it generate an exception with the error
that it couldn't find the specified objects in my resources. I checked
the
resource and there is no resource with this name there.

What is wrong with this?


As I mentioned in vc.language, It should work, so you have to find out why
it doesn't get added.
Have you tried to add image1 manually?

double click the resource, select 'images' in the top left of the resource
window.
that way you see what images exist.
In the resource window, Select Add resource->New image then select the
correct extension and add your image manually.

--

Kind regards,
Bruno.
br**********************@hotmail.com
Remove only "_nos_pam"
Mar 12 '06 #2
ma
Thanks for your suggestion.
I did some more work and I found that the resouirce is actually there but
when I try to read it i am getting the following error:
An unhandled exception of type
'System.Resources.MissingManifestResourceException ' occurred in mscorlib.dll

Additional information: Could not find any resources appropriate for the
specified culture or the neutral culture. Make sure
"test_win_form.MainForm.resources" was correctly embedded or linked into
assembly "test_win_form" at compile time, or that all the satellite
assemblies required are loadable and fully signed.

what is culture?

best regards

"Bruno van Dooren" <br**********************@hotmail.com> wrote in message
news:OT*************@TK2MSFTNGP10.phx.gbl...
but when I am running my program, it generate an exception with the error
that it couldn't find the specified objects in my resources. I checked
the
resource and there is no resource with this name there.

What is wrong with this?


As I mentioned in vc.language, It should work, so you have to find out why
it doesn't get added.
Have you tried to add image1 manually?

double click the resource, select 'images' in the top left of the resource
window.
that way you see what images exist.
In the resource window, Select Add resource->New image then select the
correct extension and add your image manually.

--

Kind regards,
Bruno.
br**********************@hotmail.com
Remove only "_nos_pam"

Mar 12 '06 #3
> Thanks for your suggestion.
I did some more work and I found that the resouirce is actually there but
when I try to read it i am getting the following error:
An unhandled exception of type
'System.Resources.MissingManifestResourceException ' occurred in mscorlib.dll

Additional information: Could not find any resources appropriate for the
specified culture or the neutral culture. Make sure
"test_win_form.MainForm.resources" was correctly embedded or linked into
assembly "test_win_form" at compile time, or that all the satellite
assemblies required are loadable and fully signed.

what is culture?


If you want users from different countries to be able to use your
application in their native language, you can use localization.

if you look at the propery page of your windows form, there is a property
called language. if you select a language there, every make-up action you
perform on the form will be tied to that language.

For example, in your case this would mean that you would have 2 pictures for
2 languages. the language is determine by the localization settings in the
windows control panel.

If the program runs on a computer for which there is no specific resource,
the program will try to load the language 'neutral' resource.

I suggest you do the following: In your resource file (if you right click it
in the solution explorer ->view code) you can see the language for which the
picture was added. In my project this is neutral (the default setting).
My guess is that whatever you find there is not neutral, and different from
the locale of your machine.

When you start your app, the program will try to load the resource for the
locale of your machine, does not find it, tries to load the neutral resource,
cannot find it and finally throws an exception.

--

Kind regards,
Bruno.
br**********************@hotmail.com
Remove only "_nos_pam"

Mar 13 '06 #4
ma
Thanks for your good explanation.

I check and found that the language of my form is default and in the
resource the culture is neutral

See the extract from my form resource:

assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />

<data name="pictureBox1.Image" type="System.Drawing.Bitmap, System.Drawing"
mimetype="application/x-microsoft.net.object.bytearray.base64">

<value>

What should I do now?

Best regards
Mar 13 '06 #5


"ma" wrote:
Thanks for your good explanation.

I check and found that the language of my form is default and in the
resource the culture is neutral

See the extract from my form resource:

assembly alias="System.Drawing" name="System.Drawing, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />

<data name="pictureBox1.Image" type="System.Drawing.Bitmap, System.Drawing"
mimetype="application/x-microsoft.net.object.bytearray.base64">

<value>

What should I do now?

Best regards


This should be OK.
Btw I just realized that your form has localization disabled .otherwise you
won't get the explicit initialization of the picturebox directly in your code.

However, your code contains this:
resources->GetObject(L"image1.Image")));
but your resource file contains this:
<data name="pictureBox1.Image"

the names don't match. there is no image1.image in your resource file.
try to change the name of the resource that initializecomponent tries to
load to the name that is in your resource file. they should be the same.

--

Kind regards,
Bruno.
br**********************@hotmail.com
Remove only "_nos_pam"

Mar 13 '06 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Bruce Davis | last post: by
11 posts views Thread by Kostatus | last post: by
9 posts views Thread by Sudesh Sawant | last post: by
117 posts views Thread by Peter Olcott | last post: by
17 posts views Thread by Jon Slaughter | last post: by
28 posts views Thread by Jon Davis | last post: by
6 posts views Thread by Ammar | last post: by
2 posts views Thread by Mike Collins | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.