Could not find any resources appropriate for the specified culture - c#

I run QBSBM project in other system it is working. But not in mine.
I saw few links in Google. For there suggestion I did few changes like changing BuildAction set to Embedded resource and resource file. And Access Modifier is also set to Public (double click the .resx file to open the file and the Access Modifier is located along the top of the editor window).
Could not find any resources appropriate for the specified culture or the neutral culture.
Make sure Manufacturing.Images.resources was correctly embedded or linked into assembly QBSBM at compile time. Or that all the satellite assemblies required are loadable and fully signed.
Can any one give me suggestion how can i solve this error...

You shoud change your resource build action. In order to do that, on the solution explorer, go to the resource property pane and change the Build Action from content to Embedded Resource.

Related

Use solution-wide resources with WinForms

I have a Visual Studio 2017 solution, which is split in several C#-WinForm applications.
To have a similar user interface I put all the icons/pictures into one project (ResourceProject) and marked the resource file public.
By directly editing the .Designer-file of a Form I can now explicitly assign the Image to something from the resource file of the ResourceProject by stating
button1.Image = ResourceProject.Properties.Resources.DemoPic
However, from time to time, the designer overwrites this with
button1.Image = ((System.Drawing.Image)resources.GetObject("button1.Image")));
and creates a local resource file, which has the image embedded.
This is exactly what I wanted to avoid in the first place, since I might want to alter easily some icons later on and have those changes directly spread over all projects.
The only way to avoid it seems to be to assign the images not in the Designer file but in some other method in the actual form file.
Is there any other way around this problem?
You should not change designer.cs file, it's auto-generated and any change which you make in the file will be replaced with auto-generated code the next time which you change something in the form.
But to share image resources between multiple projects in a solution with design-time support, you can follow these steps:
Create a class library project, let's call it ResourceLibrary.
Add a Resx resource file to the root folder of the project with this name Resources.Resx.
Open the resource designer and change its Access Modifier to Public. (It will set its Custom Tool to PublicResXFileCodeGenerator)
Add a few images to the resource designer and save it.
Then in the Windows forms project do the following settings:
Add a reference to ResourceLibrary.
Right click on windows forms project and choose Add → Existing item...
Browse to the ResourceLibrary folder and choose Resources.Resx file.
Click on drop-down arrow of the Open button, and choose Add As Link.
Select Resource.Resx which has added to windows forms project and choose properties.
Set its Build Action to None
Set its Custom Tool to a text like None
Set its Custom Tool Namespace to the namespace of the resource in the other assembly: ResourceLibrary.
Rebuild the project.
Then for all the image properties you can choose the other resource file from drop-down in the Select Resource dialog. The code generation will generate correct code for the property and you have a correct build and it works as expected at design-time as well as run-time.
You can clone or download a working example here:
Repository
Download

How can I share resources across multiple projects within a C# solution?

I have multiple projects in a solution and I'd like them all to share one pool of graphics resources. I've tried this:
1 - Created project1, made its resource file public, added some graphics to it.
2 - Created project2, Alt+dragged Resources.resx from project1\Properties to project2 (not in the Properties folder)
3 - Add reference in project2 to project1
So, now all the images from project1 are available in project2. So far, so good. I can use them at design time just fine.
But, when I want to access them at runtime, I try this (in project2)...
Image img = project1.Properties.Resources.image14;
And that crashes with a MissingManifestResourceException.
What am I doing wrong here? Is there a better way I could approach this? All I'm trying to do is maintain all my graphics in one place, so if I add a resource, it becomes available to all projects in the solution.
Just built an example following these steps:
Create a class library do hold the resources (Project 1)
Create the consumer project (Project 2)
Add a resource file (GlobalResources.resx) in the Project 1 and add a resource item Information
Change the BuildAction of the resource file to Embedded Resource
Change the Do not copy of the resource file to False
Check if the Custom Tool of the resource file is set to PublicResXFileCodeGenerator
Add a reference to the class library (Project 1) to the consumer project (Project2).
Add the resource namespace reference wherever you want to use it.
Finally it is working: GlobalResources.Information
It should be simple.
Edit:
You are concerned about using an external resource file inside the design time property editor. Sorry to inform that there is no standard support for this :(
However, if you think that the benefits are greater than the effort:
Issue with shared WinForms resources across projects in Visual Studio
How do I get the Windows Forms Designer to use resources from external assembly?
Hope it helps.
Choose the referenced file in your solution explorer, then properties, then see what the "copy to output" property looks like. I suspect it's not set to "Copy Always" or "Copy if Newer" of which either should be fine.
Once it's being copied, let's also check to see where it's being copied. Is the output path for that particular item the same as where the program ultimately expects? Is it being copied to the bin\Debug of the correct project?
Make sure it's being copied to the path where the MissingManifestResourceException says it's failed to find the resource.
Finally, given additional information in our comments, I would also suggest you verify the following:
culture the resources are targeting. Check spelling and capitalization.
any culture settings of your build xml or publish xml.
culture setting(s?) of your host system that's running this code.

C# Silverlight - How do I access a file that I set as a "resource"?

I want to embed a dictionary file as a resource into my project so that it's part of the application instead of just a separate file. The function to load the dictionary will take either a URi or a string as the path to the file. (Example: spellChecker.MainDictionary.LoadAsync(URiToMyDictionaryFile);).
How do I access a file set as "resource" or "embedded resource"? Also, what' the difference between the two?
The goal is just to have the file as part of the application so I don't have to worry about making sure it's included when the app is distributed.
Thanks again!
-Sootah
The difference between "Embedded Resource" and a "Resource" from Silverlight's point of view is that Silverlight can't access an "Embedded Resource" so don't use it.
To access a file added to the dll assembly as a "Resource" you need to add the name of the assembly plus ";component" as the first element of the Uri that accesses it:-
spellChecker.MainDictionary.LoadAsync(new Uri("/yourProjectName;component/yourDictionary.dic",UriKind.Relative));
If you are building a XAP (that is you're not creating a Silverlight library) then have you considered using "Content" instead of "Resource". This includes the file as part of the XAP alongside the dll rather than storing it in the dll.

System.Resources.MissingManifesResourceException - What's causing this?

I just added an image resource to my assembly via the Resources tab in the project properties of my project. The resource is a PNG image. Now when I load the assembly, I'm getting the error shown below. This is occurring in VS 2010.
System.Resources.MissingManifestResourceException: Could not find any resources
appropriate for the specified culture or the neutral culture.
Anyone know what is causing this?
Thanks very much.
Did you set the resource to be embedded?
Check the path in the project explorer within VS, suppose you have this path (from the root of the project), root -> resources -> foobar.png, then the full resource path would be [namespace of your project] followed by resources.foobar.png, for example, suppose the namespace is 'foobar' then it would be "foobar.resources.foobar.png"

Embedding Images In Programs?

I have a C# WinForm application that has a few images on it.
I can specify the image location, but what I want is for the image to go with the file after it publishes. It still displays the one specified in the image location, so if a user doesn't have access to that location, he/she won't be able to see the image.
The magic word you're looking for is "resources". Have a look at the MSDN article on Adding and Editing Resources.
In addition to Thomas link, you can try the following:
Add an Image into your form. Change in the properties "Build Action" field. The Build Action property indicates what Visual Studio does with a file when a build is executed. Build Action can have one of several values:
None - The file is not included in the project output group and is not compiled in the build process. An example is a text file that contains documentation, such as a Readme file.
Compile - The file is compiled into the build output. This setting is used for code files.
Content - The file is not compiled, but is included in the Content output group. For example, this setting is the default value for an .htm or other kind of Web file.
Embedded Resource - This file is embedded in the main project build output as a DLL or executable. It is typically used for resource files.

Categories