Hi All
I am relatively new to doing this and i think that i am making some king of
school boy error.
The error i am getting is on the following line of code.
XmlSerializer xs = new XmlSerializer(t ypeof(ImportRec ord));
The error is.
"Configurat ion system failed to initialize"
Below i have attached the class code and the XML i am attempting to work
with.
Please if any one can see what i am doing wrong i would much appreciate a
hand
Thanks
ink
//// Code Start
using System;
using System.Collecti ons.Generic;
using System.Componen tModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows. Forms;
using System.Configur ation;
using System.Xml;
using System.Xml.Seri alization;
using System.IO;
namespace AppConfigTest
{
public partial class Form1 : Form
{
public Form1()
{
InitializeCompo nent();
}
private void button2_Click(o bject sender, EventArgs e)
{
// Get the configuration file.
System.Configur ation.Configura tion config =
ConfigurationMa nager.OpenExeCo nfiguration(Con figurationUserL evel.None);
StringReader stringReader;
stringReader= new
StringReader(co nfig.GetSection ("importFormat" ).SectionInform ation.GetRawXml ());
XmlTextReader xmlReader;
xmlReader = new XmlTextReader(s tringReader);
XmlSerializer xs = new XmlSerializer(t ypeof(ImportRec ord));
ImportRecord importFormat =
(ImportRecord)x s.Deserialize(x mlReader);
}
}
[Serializable]
[XmlType("import Record")]
public class ImportRecord
{
[XmlAttribute("T ableName")]
public string TableName;
[XmlAttribute("R owIdentifier")]
public string RowIdentifier;
[XmlAttribute("I ndexOfInsertion ")]
public string IndexOfInsertio n;
[XmlAttribute("N oOfRowsPerRecor d")]
public string NoOfRowsPerReco rd;
[XmlAttribute("H eaderRowIdentif ier")]
public string HeaderRowIdenti fier;
[XmlElement("fie ldData")]
public FieldData FieldData = new FieldData();
}
[Serializable]
[XmlType("fieldD ata")]
public class FieldData
{
[XmlAttribute("C olumnName")]
public string ColumnName;
[XmlAttribute("F ieldName")]
public string FieldName;
[XmlAttribute("C olumnIndex")]
public string ColumnIndex;
[XmlAttribute("R owIndex")]
public string RowIndex;
[XmlAttribute("R equired")]
public Boolean Required;
}
}
//// Code End
//// XML String start
<importFormat >
<importRecord TableName="Good sExpected" RowIdentifier=" H"
IndexOfInsertio n="0" NoOfRowsPerReco rd="5" HeaderRowIdenti fier="">
<fieldData ColumnName="STO RAGE PROVIDER" FieldName="Comp anyID"
ColumnIndex="2" RowIndex="0" Required="True" />
<fieldData ColumnName="WAR EHOUSE" FieldName="Ware houseID" ColumnIndex="2"
RowIndex="1" Required="True" />
<fieldData ColumnName="ASN REFERENCE" FieldName="Refe renceID"
ColumnIndex="2" RowIndex="2" Required="True" />
<fieldData ColumnName="EXP ECTED DATE" FieldName="Expe ctedDate"
ColumnIndex="2" RowIndex="3" Required="True" />
<fieldData ColumnName="CUS TOMERID" FieldName="Supp lierID" ColumnIndex="2"
RowIndex="4" Required="True" />
</importRecord>
<importRecord TableName="Good sReceivedBatch" RowIdentifier=" D"
IndexOfInsertio n="1" NoOfRowsPerReco rd="1" HeaderRowIdenti fier="H">
<fieldData ColumnName="PAL LET ID" FieldName="Pall etID" ColumnIndex="1"
RowIndex="0" Required="False " />
<fieldData ColumnName="ITE M CODE" FieldName="Item ID" ColumnIndex="2"
RowIndex="0" Required="True" />
<fieldData ColumnName="QTY " FieldName="Qty" ColumnIndex="3" RowIndex="0"
Required="True" />
<fieldData ColumnName="ITE M DESCRIPTION" FieldName="Desc ription"
ColumnIndex="4" RowIndex="0" Required="False " />
</importRecord>
</importFormat>
//// XML String END 4 3645
On Oct 18, 1:50 pm, "ink" <i...@notmyemai l.comwrote:
I am relatively new to doing this and i think that i am making some king of
school boy error.
The error i am getting is on the following line of code.
XmlSerializer xs = new XmlSerializer(t ypeof(ImportRec ord));
The error is.
"Configurat ion system failed to initialize"
That sounds unlikely. It seems much more likely that it's *actually*
failing on this line:
System.Configur ation.Configura tion config =
ConfigurationMa nager.OpenExeCo nfiguration(Con figurationUserL evel.None);
Could you check this carefully, preferrably in the debugger, with a
fresh build, stepping through the code one line at a time and seeing
if it genuinely gets to the XmlSerializer constructor line?
Jon
Hi Jon
I have commented out everything except this line.
XmlSerializer xs = new XmlSerializer(t ypeof(ImportRec ord));
and still it fails.
ink
"Jon Skeet [C# MVP]" <sk***@pobox.co mwrote in message
news:11******** *************@i 13g2000prf.goog legroups.com...
On Oct 18, 1:50 pm, "ink" <i...@notmyemai l.comwrote:
>I am relatively new to doing this and i think that i am making some king of school boy error.
The error i am getting is on the following line of code.
XmlSerialize r xs = new XmlSerializer(t ypeof(ImportRec ord));
The error is.
"Configurati on system failed to initialize"
That sounds unlikely. It seems much more likely that it's *actually*
failing on this line:
System.Configur ation.Configura tion config =
ConfigurationMa nager.OpenExeCo nfiguration(Con figurationUserL evel.None);
Could you check this carefully, preferrably in the debugger, with a
fresh build, stepping through the code one line at a time and seeing
if it genuinely gets to the XmlSerializer constructor line?
Jon
is your app.config / web.config file valid? missing section handlers,
etc - try removing (or renaming) this file...
Marc
There was a funny Char in my app.config file so you were correct.
"Jon Skeet [C# MVP]" <sk***@pobox.co mwrote in message
news:11******** *************@i 13g2000prf.goog legroups.com...
On Oct 18, 1:50 pm, "ink" <i...@notmyemai l.comwrote:
>I am relatively new to doing this and i think that i am making some king of school boy error.
The error i am getting is on the following line of code.
XmlSerialize r xs = new XmlSerializer(t ypeof(ImportRec ord));
The error is.
"Configurati on system failed to initialize"
That sounds unlikely. It seems much more likely that it's *actually*
failing on this line:
System.Configur ation.Configura tion config =
ConfigurationMa nager.OpenExeCo nfiguration(Con figurationUserL evel.None);
Could you check this carefully, preferrably in the debugger, with a
fresh build, stepping through the code one line at a time and seeing
if it genuinely gets to the XmlSerializer constructor line?
Jon This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: pb |
last post by:
Hi,
I'm having problems deploying a project to win2003.
It is currently on win2000 server and works fine - it also works fine
on my development machine - win2003.
Both my machine and the new machine are running .net 1.1 sp1.
I get an error when I try to descrialize a file (with code):
XmlTextReader reader = new XmlTextReader(fileName);
|
by: Amsteel |
last post by:
I got something like this in VB.Net
<Serializable()> Public Class YQProfileC
Inherits CollectionBase
Public Sub Save2File(ByVal FileName As String)
Dim IFormatter As New BinaryFormatter()
Dim FS As FileStream = New FileStream(FileName, FileMode.Create,
FileAccess.Write, FileShare.None)
IFormatter.Serialize(FS, Me)
FS.Close()
|
by: PCH |
last post by:
I have 2 functions, one to serialize an object, and one to deserialize it.
I can serialize just fine, the problem is when I try to deserialize it
later...
I get an error:
{"Invalid BinaryFormatter stream. " }
I looked at the serialized string vs whats passed into the deserialize
|
by: alexandre martins |
last post by:
Every time i try to make Deserialize the computer gives me
the folowing error:
"End of Stream encountered before parsing was complete"
the code that i'm running is simple and is based on an
MSDN example. The CODE is BELOW this lines. If you see
something wrong or missing please answer.
Class declaration:
|
by: George Addison |
last post by:
I understand this might not be the optimal method of
deserialization, but how can I deserialize a class to
itself? Something like:
Public Sub New(Optional ByVal filename as string =
Nothing)
If Not IsNothing(filename) then
fs = New System.IO.FileStream(filename,
System.IO.FileMode.Open)
Dim sf As New
| |
by: Frank Rizzo |
last post by:
How do I serialize Font object into a string that I can store in either
INI file or the registry (I know it’s a bad thing, but need to do it
nevertheless). Then, also, how do I deserialize it from that string
back into a font object?
Thanks.
|
by: Matt S |
last post by:
Hello,
I'm trying to build a C# client to consume an AXIS Web Service (running SOAP
over HTTP). The Web Service encodes
full server-side exception traces in the Soap Fault > Detail element using
complex type structures declared in
the WSDL file.
|
by: Thomas S |
last post by:
Any suggestions on how to deserialize an object from one line of XML?
I'm trying to deserialize multiple objects from one XML document, each
object on one line of the file. The serialization is working, but when I
try to read the line back into a MemoryStream, and then to deserialize from
that, I get an error that the root node doesn't...
|
by: Anbu |
last post by:
Hi All,
I need to Deserialize the SoapService's SoapEnvelope response object.
Here is the Body of the SoapEnvelope received as respone,
<q1:serviceResponse xmlns:q1="urn:CallSetup"><serviceReturn
xsi:type="q1:response"
xmlnssi="http://www.w3.org/2001/XMLSchema-instance">ok</serviceReturn></q1:serviceResponse>
|
by: wpmccormick |
last post by:
I've a complex problem:
I'm deserializing a very long string of XML into a very large object
foo:
<foo>
.......
<bar>sometimes a simple string is here</bar>
.......
</foo>
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
|
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
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 then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |