473,385 Members | 1,740 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,385 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 2226

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: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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
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...

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.