9 Replies - 2717 Views - Last Post: 21 October 2014 - 12:59 PM Rate Topic: -----

#1 RozenKristal   User is offline

  • D.I.C Regular

Reputation: 45
  • View blog
  • Posts: 381
  • Joined: 29-September 12

Unable to load resources from .resx

Posted 17 October 2014 - 07:22 AM

Here I am again, sorry for asking too much questions folks...
So I been upgrading the projects of a system to 4.5.1 framework from 3.5. Then there is this one project that fail to load the bitmap image from resx. That particular project upgrading log showed no error or anything weird. The method I use to get the resx was pretty straight forward too.
ResourceFileName.[imagename]


Then I get this:
An unhandled exception of type 'System.Collections.Generic.KeyNotFoundException' occurred in mscorlib.dll

Additional information: The given key was not present in the dictionary.


Any idea would be appreciated.

Is This A Good Question/Topic? 0
  • +

Replies To: Unable to load resources from .resx

#2 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 15427
  • View blog
  • Posts: 61,791
  • Joined: 12-June 08

Re: Unable to load resources from .resx

Posted 17 October 2014 - 07:51 AM

Are you sure the .RESX file is there?

Do you need to add it back to the project?

If you right click your project -> settings.. do you see your variable name there?
Was This Post Helpful? 0
  • +
  • -

#3 RozenKristal   User is offline

  • D.I.C Regular

Reputation: 45
  • View blog
  • Posts: 381
  • Joined: 29-September 12

Re: Unable to load resources from .resx

Posted 17 October 2014 - 10:50 AM

Yes, I think I can access it locally. But when some other project call that particular project remotely (thru a dll reference), I get that error. I am wondering if that is the issue. Was the way resource was handle differently for VS 2013? I work on a winform proj if that help.
Was This Post Helpful? 0
  • +
  • -

#4 RozenKristal   User is offline

  • D.I.C Regular

Reputation: 45
  • View blog
  • Posts: 381
  • Joined: 29-September 12

Re: Unable to load resources from .resx

Posted 17 October 2014 - 11:06 AM

View Postmodi123_1, on 17 October 2014 - 07:51 AM, said:

Are you sure the .RESX file is there?

Do you need to add it back to the project?

If you right click your project -> settings.. do you see your variable name there?


When I right click and go to project settings, there is nothing there.
Was This Post Helpful? 0
  • +
  • -

#5 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 15427
  • View blog
  • Posts: 61,791
  • Joined: 12-June 08

Re: Unable to load resources from .resx

Posted 17 October 2014 - 11:42 AM

Maybe you need to rebuild it. See about adding it back, manually.
Was This Post Helpful? 0
  • +
  • -

#6 RozenKristal   User is offline

  • D.I.C Regular

Reputation: 45
  • View blog
  • Posts: 381
  • Joined: 29-September 12

Re: Unable to load resources from .resx

Posted 17 October 2014 - 11:45 AM

View Postmodi123_1, on 17 October 2014 - 11:42 AM, said:

Maybe you need to rebuild it. See about adding it back, manually.


Already do that. It doesn't work. Apparently it was able to find the DLL but somehow can't grab the resources.
Was This Post Helpful? 0
  • +
  • -

#7 RozenKristal   User is offline

  • D.I.C Regular

Reputation: 45
  • View blog
  • Posts: 381
  • Joined: 29-September 12

Re: Unable to load resources from .resx

Posted 20 October 2014 - 09:21 AM

Okay. So after testing, we found that the program went and got access to the .dll of project that has the resource. It does see the project, but it can't grab the resource files inside. So I guess the problem is it unable to get the resources through the dll.
Was This Post Helpful? 0
  • +
  • -

#8 Skydiver   User is offline

  • Code herder
  • member icon

Reputation: 7187
  • View blog
  • Posts: 24,356
  • Joined: 05-May 12

Re: Unable to load resources from .resx

Posted 21 October 2014 - 05:31 AM

Can you do a quick test by adding a few lines of code to enumerate all the resources in the assembly? GetManifestResourceNames()

Compare the resulting returned strings with the strings you are using in your code. Be aware that case matters when loading resources.
Was This Post Helpful? 0
  • +
  • -

#9 RozenKristal   User is offline

  • D.I.C Regular

Reputation: 45
  • View blog
  • Posts: 381
  • Joined: 29-September 12

Re: Unable to load resources from .resx

Posted 21 October 2014 - 07:19 AM

I compared the string... it is correct :(/>... Well, in the mean time, have to work around this problem. I made a folder which contains all the images, so when one function need it, it can go to the path and grab the image, return a bitmap. However, my form still doesnt display it. This is my code for returning an icon, do you see any problem with it?, or is there a new way to get an icon from an image in 4.5.1?

this.Icon = Icon.FromHandle(new Bitmap(bm).GetHicon());

Got this one working.. Thank you guys. I think i will stick with the work around.

This post has been edited by RozenKristal: 21 October 2014 - 07:41 AM

Was This Post Helpful? 0
  • +
  • -

#10 Skydiver   User is offline

  • Code herder
  • member icon

Reputation: 7187
  • View blog
  • Posts: 24,356
  • Joined: 05-May 12

Re: Unable to load resources from .resx

Posted 21 October 2014 - 12:59 PM

The namespace also matters. If the namespace change or the case changed in the naming of the namespace, then you could also see problems.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1