473,396 Members | 2,020 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Configuration Block - Hashtable's values deserialization problem

Hi, I wrote a simple program to test the "out-of-the-box"
functionalities of the CMAB (Configuration Management Application
Block).
After having added 2 values to an hashtable, and having written that
hashtable (using the XmlHashtableSectionHandler) to an XML file (using
the XmlFileStorage) I try to read back the hashtable with those
values. I am adding a "string" value (with a string key) and a
"double" value (also with a string key) to the hashtable.

The problem is that even though it all seems fine in the xmlStorage
file, when I read back the hashtable from the Configurationmanager,
and try to get both the string and double value back, it seems that
they are both restored as strings, I mean, the hashtable (restored
from the xmlStorage file) has the double value converted as a string,
although it was stored as a double. So, an InvalidCastException is
thrown when I try to get the double value.

Anyone knows what the problem might be?
Thanks in advance,
Ricardo Pereira

*******************************
Piece of code where I read the hashtable:
*******************************

Hashtable table;

table=(Hashtable)ConfigurationManager.Read();

string s = (string)table["ip"];
double x = (double)table["numberOfX"];
********
App.config:
********

<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="applicationConfigurationManagement"
type="Microsoft.ApplicationBlocks.ConfigurationMan agement.ConfigurationManagerSectionHandler,Microso ft.ApplicationBlocks.ConfigurationManagement,Versi on=1.0.0.0,Culture=neutral,PublicKeyToken=null"
/>
<section name="TestXMLConfiguration"
type="Microsoft.ApplicationBlocks.ConfigurationMan agement.XmlHashtableSectionHandler,Microsoft.Appli cationBlocks.ConfigurationManagement,Version=1.0.0 .0,Culture=neutral,PublicKeyToken=null"
/>
</configSections>
<applicationConfigurationManagement
defaultSection="TestXMLConfiguration">
<configSection name="TestXMLConfiguration">
<configProvider assembly="Microsoft.ApplicationBlocks.Configuratio nManagement,Version=1.0.0.0,Culture=neutral,Public KeyToken=null"
type="Microsoft.ApplicationBlocks.ConfigurationMan agement.Storage.XmlFileStorage"
path="MyXML.xml"
signed="false" encrypted="false" />
</configSection>
</applicationConfigurationManagement>
</configuration>

********
MyXML.xml:
********

<?xml version="1.0" encoding="utf-8"?>
<configuration>
<TestXMLConfiguration>
<XmlSerializableHashtable
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<Entries>
<Entry>
<key xsi:type="xsd:string">ip</key>
<value xsi:type="xsd:string">192.1683.1.1</value>
</Entry>
<Entry>
<key xsi:type="xsd:string">numberOfX</key>
<value xsi:type="xsd:double">4</value>
</Entry>
<Entry>
<key xsi:type="xsd:string">numberOfY</key>
<value xsi:type="xsd:double">3.4</value>
</Entry>
</Entries>
</XmlSerializableHashtable>
</TestXMLConfiguration>
</configuration>
Jul 21 '05 #1
0 2227

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Shane | last post by:
Does anyone have a simple and easy to use example of how to use this App. Block? Something along the lines of... 1) Create an application configuration file. 2) Put these lines in it.... ...
1
by: Jason | last post by:
Hi, I'm trying to integrate Microsoft's Configuration Management Application Block (CMAB), and have run into a bit of trouble. Would appreciate any input anybody could provide at this point. I...
7
by: | last post by:
In the beginning we had Ini files. Later we had registery files. Now have xml files and our read-only myapp.config file. My question now, is what is the best way to store and load user and...
4
by: André Giesing | last post by:
Hello NG! I've got a short question: Is there a difference of the internal representation of a Hashtable between the Compact Framework and the normal Framework? I've got the suspicion,...
1
by: Rab | last post by:
Hi everyone I`m having a problem extracting some values from an app.config file. I`m storing a collection of name value pairs in the config file, and retreiving them using a custom handler that...
1
by: Robert N | last post by:
I was able to compile (Debug) and reference an Configuration Block project for my primary application "AppPrimary.exe". When I add a strong name file to the Configuration Block project and...
3
by: MioTheGreat | last post by:
I know how to take a single hashtable, and then use a binaryformatter and a filestream to dump it to a file, but I need to serialize and deserialize a hashtable inside a class. I've been trying...
0
by: Ricardo Pereira | last post by:
Hi, I wrote a simple program to test the "out-of-the-box" functionalities of the CMAB (Configuration Management Application Block). After having added 2 values to an hashtable, and having written...
2
by: UJ | last post by:
How do you add a new value to a configuration file through the configuration block through code? When I try and add a new value I get an exception. TIA - Jeff.
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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
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
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.