Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / Managed C++ / March 2006

Tip: Looking for answers? Try searching our database.

problem with pictuerbox

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
ma - 12 Mar 2006 22:05 GMT
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
Bruno van Dooren - 12 Mar 2006 22:18 GMT
> 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.

Signature

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

ma - 12 Mar 2006 23:00 GMT
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

>> 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
[quoted text clipped - 12 lines]
> In the resource window, Select Add resource->New image then select the
> correct extension and add your image manually.
Bruno van Dooren - 13 Mar 2006 08:46 GMT
> Thanks for your suggestion.
> I did some more work and I found that the resouirce is actually there but
[quoted text clipped - 9 lines]
>
> 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.

Signature

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

ma - 13 Mar 2006 10:14 GMT
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
Bruno van Dooren - 13 Mar 2006 10:48 GMT
> Thanks for your good explanation.
>
[quoted text clipped - 14 lines]
>
> 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.

Signature

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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.