-
Assembly assembly = Assembly.GetExecutingAssembly();
-
ResourceManager rm = new ResourceManager("NameSpace.Demo", assembly, null);
-
try
-
{
-
logo.Image = (Image)rm.GetObject("WroxLogo");
-
textTitle.Text = rm.GetString("Title");
-
}
-
catch (Exception ex)
-
{
-
MessageBox.Show(ex.Message.ToString());
-
}
Hi, I created a Demo.resx and I included it to my project, when I try to compile it showing. Error :Invalid Resx file. Invalid character in the given encoding. Line 1, position 1. <File Path>\Demo.resx
Can any one explain why this error is occurring and how to rectify it?
Front-end : C# 2005
5 15698 Plater 7,872
Recognized Expert Expert
Umm, resx files look NOTHING like that.
Are you sure you don't want a new class file?
This is an example of a resx file: -
<?xml version="1.0" encoding="utf-8"?>
-
<root>
-
<!--
-
Microsoft ResX Schema
-
-
Version 2.0
-
-
The primary goals of this format is to allow a simple XML format
-
that is mostly human readable. The generation and parsing of the
-
various data types are done through the TypeConverter classes
-
associated with the data types.
-
-->
-
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
-
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
-
<xsd:element name="root" msdata:IsDataSet="true">
-
<xsd:complexType>
-
<xsd:choice maxOccurs="unbounded">
-
<xsd:element name="metadata">
-
<xsd:complexType>
-
<xsd:sequence>
-
<xsd:element name="value" type="xsd:string" minOccurs="0" />
-
</xsd:sequence>
-
<xsd:attribute name="name" use="required" type="xsd:string" />
-
<xsd:attribute name="type" type="xsd:string" />
-
<xsd:attribute name="mimetype" type="xsd:string" />
-
<xsd:attribute ref="xml:space" />
-
</xsd:complexType>
-
</xsd:element>
-
<xsd:element name="assembly">
-
<xsd:complexType>
-
<xsd:attribute name="alias" type="xsd:string" />
-
<xsd:attribute name="name" type="xsd:string" />
-
</xsd:complexType>
-
</xsd:element>
-
<xsd:element name="data">
-
<xsd:complexType>
-
<xsd:sequence>
-
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
-
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
-
</xsd:sequence>
-
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
-
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
-
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
-
<xsd:attribute ref="xml:space" />
-
</xsd:complexType>
-
</xsd:element>
-
<xsd:element name="resheader">
-
<xsd:complexType>
-
<xsd:sequence>
-
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
-
</xsd:sequence>
-
<xsd:attribute name="name" type="xsd:string" use="required" />
-
</xsd:complexType>
-
</xsd:element>
-
</xsd:choice>
-
</xsd:complexType>
-
</xsd:element>
-
</xsd:schema>
-
<resheader name="resmimetype">
-
<value>text/microsoft-resx</value>
-
</resheader>
-
<resheader name="version">
-
<value>2.0</value>
-
</resheader>
-
<resheader name="reader">
-
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
-
</resheader>
-
<resheader name="writer">
-
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
-
</resheader>
-
</root>
-
Thank you plater. -
ResourceWriter rw = new ResourceWriter("Demo.resx");
-
using (Image image = Image.FromFile("logo.gif"))
-
{
-
rw.AddResource("WroxLogo", image);
-
rw.AddResource("Title", "Professional C#");
-
}
Actually, I am encoding a .gif file and created a resx file through code then referred(Added) to my project.
I am unable to understand the concept of ‘Resource writer’, ‘Resource Reader’, and ‘Resource Manager’. Can any one give some simple example to understand the concept (and if you have time please give with explanation)?
Thank you.
I am getting this Exception.. "Could not find any resources appropriate for the specified culture or the neutral culture. Make sure \"Demo.resources\" was correctly embedded or linked into assembly \"NameSpace\" at compile time, or that all the satellite assemblies required are loadable and fully signed."
Till i am trying...
Changed the Code like
ResourceManager rm = new ResourceManager("Demo", Assembly.LoadFile(@"filePath/Demo.resources"));
Now, Here i am getting error
My AssemblyVersion is -
[assembly: AssemblyVersion("1.0.0.0")]
-
[assembly: AssemblyFileVersion("1.0.0.0")]
I am Creating Resource file -
ResourceWriter rw = new ResourceWriter("Demo.resources");
-
using (Image image = Image.FromFile("logo.gif"))
-
{
-
rw.AddResource("WroxLogo", image);
-
rw.AddResource("Title", "Professional C#");
-
rw.Close();
-
}
I added the resource file to my project and in below code i am get back my image and title -
ResourceManager rm = new ResourceManager("Demo", Assembly.GetExecutingAssembly());
-
try
-
{
-
logo.Image = (Image)rm.GetObject("WroxLogo");
-
textTitle.Text = rm.GetString("Title");
-
}
-
//Catch Block here
-
- logo.Image = (Image)rm.GetObject("WroxLogo");
in this line My problem Starts and showing error
"Could not find any resources appropriate for the specified culture or the neutral culture. Make sure \"Demo.resources\" was correctly embedded or linked into assembly \"Namespace\" at compile time, or that all the satellite assemblies required are loadable and fully signed."
Can any one explain me why this Exception is throwing?
I solved my problem.
I am using ResourceManager, which is wrong I have to use ResourceSet
ResourceSet rs = new ResourceSet("Demo.resources");
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Frank Jones |
last post by:
When manually running resgen.exe from the command prompt (Visual Studio .NET
2003 command prompt) I get the following error:
error: Invalid ResX input.
error: Specific exception:...
|
by: David Krussow |
last post by:
I had an aspx page (mypage.aspx) with a code behind file (mypage.aspx.cs)
that in turn had a resx file (mypage.aspx.resx). I decided to create another
aspx page (myotherpage.aspx) that would reuse...
|
by: strout |
last post by:
Do we need to deploy these type of file on server. Is .resx file embedded
into dll or not? If not we should include resx file, right?
strout
|
by: prabhupr |
last post by:
Hi Folks
I'm currently working on a Localization+Globalization project; for this
project, we need to generate ".Resx" files and we use "US English" Resx
file as the base version, to compare the...
|
by: Steave |
last post by:
Hi, using Managed C++ (.Net 2.0), I want to embed some images within an
executable using a .resX file, and upon an event (in this case a combo
box changing), I want the picture box to update with a...
| |
by: Rahul |
last post by:
Hi I have a Project A that is being reffered by another WEB project
Webber.
In Project A i am using a resx file to store some information in it.
I have m1de the Build Action of the Resx file to...
|
by: Sister Ray |
last post by:
Hello,
I'm trying to debug and compile a application that was developed by a
collegue of mine, How ever when i try to build the application I
always receive the following error:
Compiling...
|
by: Peter Afonin |
last post by:
Hello,
I'm new to Crystal reports. Recently I developed my first report, using
class as a datasource, and it works OK. But when I created a second report,
I started getting error: "Invalid...
|
by: raylopez99 |
last post by:
I have the latest version of Visual Studio 2008 Professional, which
allows you to create resource files (this is the .resx file, no?),
unlike the Express version, which does not.
I am trying to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The...
| |
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |