Blog Archive

José Quinto Zamora

Embedding resources in Visual Studio 2010, neutral culture problem

2011-02-24 16:09:00 by José Quinto Zamora

Many times, we need to add some embed resources to our Visual Studio 2010 project.

In Visual Studio 2008 we only will drag and drop our file to Resources project and then make reference to My.Resources.<ResourceName>. But in VS 2010 when we do it, we receive following error:

Could not find any resources appropriate for the specified culture or the neutral culture.  Make sure "My.Resources.Resources.resources" was correctly embedded or linked into assembly "SolidQ.SPS.WebParts" at compile time, or that all the satellite assemblies required are loadable and fully signed.

What is the solution?

We need take in account three points:


1. Our resource file have “Embedded Resource” type in Build Action.




2. Our resource file is in Resources.resx (Resources tab in Project properties)




3. Our Namespace is configured in ResourceManager.

To verify this, go to Resources.Designer.vb file:



Then go to this method and change text parameter at ResourceManager instance, that is “My.Resources.Resources”. You must put your project namespace.

'''  Returns the cached ResourceManager instance used by this class.
<Global.System.ComponentModel.EditorBrowsableAttribute(Global.System.ComponentModel.EditorBrowsableState.Advanced)> _
Public ReadOnly Property ResourceManager() As Global.System.Resources.ResourceManager
		If Object.ReferenceEquals(resourceMan, Nothing) Then
			Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("My.Resources.Resources", GetType(Resources).Assembly)
			resourceMan = temp
		End If
		Return resourceMan
	End Get
End Property


In other words, you must put this line (for example):

Dim temp As Global.System.Resources.ResourceManager = New Global.System.Resources.ResourceManager("SolidQ.SPS.WebParts.Resources", GetType(Resources).Assembly)


By the way, in order to make replacements in the resource files, I do this:

- Put phrases to replace between @. For instance: @ContentTypesToSave@

- By code, access to resource and replace the text for any variable:

 Dim res As String = My.Resources.HideRibbonJavaScript.ToString
 res = res.Replace("@ContentTypesToSave@", stringCTypes)



- Daniel Seara wisdom.

- Could not find any resources appropriate for the specified culture or the neutral culture





No Comments
Leave a Comment
(*) Title:
(*) Name:
Your URL:
(*) Comments:
Follow us on: