473,508 Members | 2,152 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Error : Invalid Resx file

487 Recognized Expert Contributor
Expand|Select|Wrap|Line Numbers
  1. Assembly assembly = Assembly.GetExecutingAssembly();
  2. ResourceManager rm = new ResourceManager("NameSpace.Demo", assembly, null);
  3.             try
  4.             {
  5.                 logo.Image = (Image)rm.GetObject("WroxLogo");
  6.                 textTitle.Text = rm.GetString("Title");
  7.             }
  8.             catch (Exception ex)
  9.             {
  10.                 MessageBox.Show(ex.Message.ToString());
  11.             }
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
Nov 7 '07 #1
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:
Expand|Select|Wrap|Line Numbers
  1. <?xml version="1.0" encoding="utf-8"?>
  2. <root>
  3. <!-- 
  4.     Microsoft ResX Schema 
  5.  
  6.     Version 2.0
  7.  
  8.     The primary goals of this format is to allow a simple XML format 
  9.     that is mostly human readable. The generation and parsing of the 
  10.     various data types are done through the TypeConverter classes 
  11.     associated with the data types.
  12. -->
  13.   <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
  14.     <xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
  15.     <xsd:element name="root" msdata:IsDataSet="true">
  16.       <xsd:complexType>
  17.         <xsd:choice maxOccurs="unbounded">
  18.           <xsd:element name="metadata">
  19.             <xsd:complexType>
  20.               <xsd:sequence>
  21.                 <xsd:element name="value" type="xsd:string" minOccurs="0" />
  22.               </xsd:sequence>
  23.               <xsd:attribute name="name" use="required" type="xsd:string" />
  24.               <xsd:attribute name="type" type="xsd:string" />
  25.               <xsd:attribute name="mimetype" type="xsd:string" />
  26.               <xsd:attribute ref="xml:space" />
  27.             </xsd:complexType>
  28.           </xsd:element>
  29.           <xsd:element name="assembly">
  30.             <xsd:complexType>
  31.               <xsd:attribute name="alias" type="xsd:string" />
  32.               <xsd:attribute name="name" type="xsd:string" />
  33.             </xsd:complexType>
  34.           </xsd:element>
  35.           <xsd:element name="data">
  36.             <xsd:complexType>
  37.               <xsd:sequence>
  38.                 <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
  39.                 <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
  40.               </xsd:sequence>
  41.               <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
  42.               <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
  43.               <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
  44.               <xsd:attribute ref="xml:space" />
  45.             </xsd:complexType>
  46.           </xsd:element>
  47.           <xsd:element name="resheader">
  48.             <xsd:complexType>
  49.               <xsd:sequence>
  50.                 <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
  51.               </xsd:sequence>
  52.               <xsd:attribute name="name" type="xsd:string" use="required" />
  53.             </xsd:complexType>
  54.           </xsd:element>
  55.         </xsd:choice>
  56.       </xsd:complexType>
  57.     </xsd:element>
  58.   </xsd:schema>
  59.   <resheader name="resmimetype">
  60.     <value>text/microsoft-resx</value>
  61.   </resheader>
  62.   <resheader name="version">
  63.     <value>2.0</value>
  64.   </resheader>
  65.   <resheader name="reader">
  66.     <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
  67.   </resheader>
  68.   <resheader name="writer">
  69.     <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
  70.   </resheader>
  71. </root>
  72.  
Nov 7 '07 #2
CyberSoftHari
487 Recognized Expert Contributor
Thank you plater.
Expand|Select|Wrap|Line Numbers
  1.           ResourceWriter rw = new ResourceWriter("Demo.resx");
  2.           using (Image image = Image.FromFile("logo.gif"))
  3.           {
  4.              rw.AddResource("WroxLogo", image);
  5.              rw.AddResource("Title", "Professional C#");
  6.           }
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.
Nov 12 '07 #3
CyberSoftHari
487 Recognized Expert Contributor
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
Attached Images
File Type: jpg Error_80131018.JPG (17.8 KB, 588 views)
Nov 12 '07 #4
CyberSoftHari
487 Recognized Expert Contributor
My AssemblyVersion is
Expand|Select|Wrap|Line Numbers
  1. [assembly: AssemblyVersion("1.0.0.0")]
  2. [assembly: AssemblyFileVersion("1.0.0.0")]
I am Creating Resource file
Expand|Select|Wrap|Line Numbers
  1.       ResourceWriter rw = new ResourceWriter("Demo.resources");  
  2.           using (Image image = Image.FromFile("logo.gif"))
  3.           {
  4.              rw.AddResource("WroxLogo", image);
  5.              rw.AddResource("Title", "Professional C#");
  6.              rw.Close();
  7.          }
I added the resource file to my project and in below code i am get back my image and title
Expand|Select|Wrap|Line Numbers
  1. ResourceManager rm = new ResourceManager("Demo", Assembly.GetExecutingAssembly());
  2.             try
  3.             {
  4.                 logo.Image = (Image)rm.GetObject("WroxLogo");
  5.                 textTitle.Text = rm.GetString("Title");
  6.             }
  7.            //Catch Block here
  8.  
Expand|Select|Wrap|Line Numbers
  1. 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?
Nov 12 '07 #5
CyberSoftHari
487 Recognized Expert Contributor
I solved my problem.

I am using ResourceManager, which is wrong
I have to use ResourceSet
ResourceSet rs = new ResourceSet("Demo.resources");
Nov 12 '07 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

1
3867
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:...
0
499
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...
1
1596
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
0
1670
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...
0
1635
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...
0
2190
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...
1
2757
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...
2
5137
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...
8
14915
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...
0
7225
marktang
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,...
0
7124
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...
0
7326
Oralloy
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,...
0
7385
jinu1996
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...
1
7046
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...
0
7498
tracyyun
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...
0
4707
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...
0
3195
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...
0
3182
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.