.NET Framework - Resources on Classes

Asked By Lucio Menci
13-Nov-09 06:49 AM
Hi,

I d'like to use a resource file to a class is not a usercontrol.
If I edit the main .resx of the project, I can found that resource by the
command:

Dim WantedResource As Object = My.Resources.MyResrouceName

If I make a UserControl, VS create three files: a.vb, a.designer.vb and
a.resx.
If I edit the a.resx and I add a resource into it, I can use that resource
from a sub of the UserControl by the sequent commands:

Dim RSManager As New Resources.ResourceManager(Me.GetType)
Dim WantedResource As Object = RSManager.GetObject("NewImage")

I tried to create a Class is not a UserControl (b.vb), and put a new empty
file into the same directory called b.resx, create a new project, import that
Class and, if I have all files shown on the solution explorer, I see that the
b.vb have the b.resx connected. If I edit the b.resx and I add the same
resource into it, I noted that b.resx is very similar to a.resx, but if I try
to call the same commands above, the second one throws an exception
(MissingManifestResourceException). Why?
RSManager.GetObject
(1)
Resources.ResourceManager
(1)
RSManager
(1)
WantedResource
(1)
UserControl
(1)
NewImage
(1)
Directory
(1)
Resx
(1)
  Lucio Menci replied to Lucio Menci
13-Nov-09 09:20 AM
Sorry, I wrote in a wrong discussion...
help
can use that resource from a sub of the UserControl by the sequent commands: Dim RSManager As New Resources.ResourceManager(Me.GetType) Dim WantedResource As Object = RSManager.GetObject("NewImage") I tried to create a Class is not a UserControl (b.vb), and put commands above, the second one throws an exception (MissingManifestResourceException). Why? VB.NET Discussions MissingManifestResourceException (1) RSManager.GetObject (1) Resources.ResourceManager (1) ResourceManager (1) UserControl (1) GetObject (1) RSManager (1) WantedResource (1) My first thought
Cannot create System.Resources.ResourceManager object .NET Framework My problem is ResourceManager constructor is throwing an exception when used on to VS2005 and this problem is still being reported). The specific problem is the System.Resources.ResourceManager constructor is throwing an exception. The type of exception is "Exception" and the message is it MobemTest and add the following code into the main form's constructor. try{ System.Resources.ResourceManager resMan; System.Reflection.Assembly assembly = System.Reflection.Assembly.GetExecutingAssembly(); if (assembly ! = null){ resMan = new System.Resources.ResourceManager("MobemTest.Resource1", assembly); } } catch (Exception ex){ MessageBox.Show("Exception Type: " + ex.GetType().ToString()); MessageBox.Show
Fehler das er die eingebettete Resource nicht finden kann. _assy = Assembly.GetExecutingAssembly() rm = New System.Resources.ResourceManager(String.Format("{0}.{1}.{1}", _assy.GetName().Name, "Resources"), _assy) Dim ci As CultureInfo = New oder wie greife ich richtig auf die entspr. Resource zu ? VB.NET - German Discussions System.Resources.ResourceManager (1) GetManifestResourceStream (1) ChangeUICulture (1) GetExecutingAssembly (1) ResourceManager (1) String.Format (1) Hallo Stefan, mit hast: _assy = Assembly.GetExecutingAssembly() muß _assy = [Assembly].GetExecutingAssembly() heißen. Die nächste Zeile rm = New System.Resources.ResourceManager(String.Format("{0}.{1}.{1}", _assy.GetName().Name, "Resources"), _assy) scheint auch einen Fehler zu und ChangeUI ist. Wenn Du Dir die ResourceManager-Klasse anschaust (im Index ungefiltert nach System.Resources.ResourceManager suchen), wirst Du folgenden Code finden: (http: / / msdn.microsoft.com / de-de / library / system.resources
through Resources.Designer.cs and saw this code: internal class Resources { private static global::System.Resources.ResourceManager resourceMan; What is the meaning of the two colons between 'global' and 'System' in the class declaration. . . but what about two colons in a variable declaration? Thanks. C# Discussions System.Resources.ResourceManager (1) ResourceManager (1) ResourceMan (1) Inheritance (1) Htccxtad (1) Colons (1) Here you go. . . http