简体   繁体   中英

C++/CLI can't find resources

My question is similar to some I've found after googling for the last couple of hours. However, I couldn't get it to work with what I've read and I'd appreciate help. I have a C++/CLI project, called (eg) some.thing, inside a folder called some.thing with a windows form in it. I was putting all the classes in the namespace some::thing. Why? Probably I misunderstood but I had read somewhere that it was the standard. Anyway, that's not the issue here. Everything worked fine until I added, from the designer, a resource (background image) to the form. It generates a runtime exception: System.Resources.MissingManifestResourceException.

The message is Could not find any resources appropriate for the specified culture or the neutral culture. Make sure "some.thing.myForm.resources" was correctly embedded or linked into assembly "some.thing" at compile time, or that all the satellite assemblies required are loadable and fully signed

Now, for what I googled and stackoverflowed, this is not so uncommon, but the solutions offered don't work for my case, don't work for C++CLI, or aren't clear enough for my newbieness.

I tried changing the line in the form class code were gcnew System::ComponentModel::ComponentResourceManager(...) , I searched for project settings of default namespaces, I tried to see the code of the resource file, searched for some property around to define a namespace... Can't solve it. I want to be able to see the background image in the designer I'd appreciate any help

Was struggling with this in our C++/CLI project--see my comment under your original question. During runtime, when loading the form, it was looking for eg "Namespace1.Form1.Resources". But the resources file was Namespace2.Form1.resources, for example.

I managed to fix this by changing the LogicalName element under the EmbeddedResource element for each build configuration in the project. (Unloaded the project and did a find/replace in the .vcxproj file). We changed it to

<LogicalName>$(IntDir)$(RootNamespace).%(Filename).resources</LogicalName>

Those LogicalName lines were the culprits, though--they didn't match the names of the actual .resource files that were getting generated.

So, your situation might not be exactly the same, but I'll bet it's related to those LogicalName values in your project file. (There are also LogicalNamee overrides for each form, check those too if the above doesn't work--ours were empty so it was able to use the project default LogicalName for all the forms.)

I wonder if the VS upgrade from 2008 to 2010 is at fault? Our issues began at that point.

I also ran into this very annoying issue and ultimately the answer for me was to set the managed resource name property(LogicalName in the project file) to blank (empty string) and magically everything was fine after that. I suppose the compiler tries to figure it out which in my case worked. Good luck!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM