PC Review


Reply
Thread Tools Rate Thread

Configuration Block - Hashtable's values deserialization problem

 
 
Ricardo Pereira
Guest
Posts: n/a
 
      28th Jul 2004
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.ConfigurationManagement.ConfigurationManagerSectionHandler,Microsoft.ApplicationBlocks.ConfigurationManagement,Version=1.0.0.0,Culture=neutral,PublicKeyToken=null"
/>
<section name="TestXMLConfiguration"
type="Microsoft.ApplicationBlocks.ConfigurationManagement.XmlHashtableSectionHandler,Microsoft.ApplicationBlocks.ConfigurationManagement,Version=1.0.0.0,Culture=neutral,PublicKeyToken=null"
/>
</configSections>
<applicationConfigurationManagement
defaultSection="TestXMLConfiguration">
<configSection name="TestXMLConfiguration">
<configProvider assembly="Microsoft.ApplicationBlocks.ConfigurationManagement,Version=1.0.0.0,Culture=neutral,PublicKeyToken=null"
type="Microsoft.ApplicationBlocks.ConfigurationManagement.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>
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Adding values to a configuration block. UJ Microsoft C# .NET 2 16th Mar 2006 01:15 PM
Microsoft Configuration Block and Enterprise library configuration tool Mark Microsoft ASP .NET 0 15th Feb 2006 11:27 PM
Enterprise library problem, configuration block =?Utf-8?B?Sm9yZ2Fz?= Microsoft Dot NET 0 15th Nov 2005 05:05 PM
Configuration Managament Application Block and Web.Config Problem Johannes H?drich Microsoft ASP .NET 0 8th Jul 2004 09:48 AM
copy Hashtable values to another Hashtable? M Microsoft C# .NET 3 17th Oct 2003 08:02 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:36 AM.