Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 117977
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T03:25:18+00:00 2026-05-11T03:25:18+00:00

Expanding upon my earlier problem , I’ve decided to (de)serialize my config file class

  • 0

Expanding upon my earlier problem, I’ve decided to (de)serialize my config file class which worked great.

I now want to store an associative array of drive letters to map (key is the drive letter, value is the network path) and have tried using Dictionary, HybridDictionary, and Hashtable for this but I always get the following error when calling ConfigFile.Load() or ConfigFile.Save():

There was an error reflecting type ‘App.ConfigFile’. [snip] System.NotSupportedException: Cannot serialize member App.Configfile.mappedDrives [snip]

From what I’ve read Dictionaries and HashTables can be serialized, so what am I doing wrong?

[XmlRoot(ElementName='Config')] public class ConfigFile {     public String guiPath { get; set; }     public string configPath { get; set; }     public Dictionary<string, string> mappedDrives = new Dictionary<string, string>();      public Boolean Save(String filename)     {         using(var filestream = File.Open(filename, FileMode.OpenOrCreate,FileAccess.ReadWrite))         {             try             {                 var serializer = new XmlSerializer(typeof(ConfigFile));                 serializer.Serialize(filestream, this);                 return true;             } catch(Exception e) {                 MessageBox.Show(e.Message);                 return false;             }         }     }      public void addDrive(string drvLetter, string path)     {         this.mappedDrives.Add(drvLetter, path);     }      public static ConfigFile Load(string filename)     {         using (var filestream = File.Open(filename, FileMode.Open, FileAccess.Read))         {             try             {                 var serializer = new XmlSerializer(typeof(ConfigFile));                 return (ConfigFile)serializer.Deserialize(filestream);             }             catch (Exception ex)             {                 MessageBox.Show(ex.Message + ex.ToString());                 return new ConfigFile();             }         }     } } 
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T03:25:18+00:00Added an answer on May 11, 2026 at 3:25 am

    You can’t serialize a class that implements IDictionary. Check out this link.

    Q: Why can’t I serialize hashtables?

    A: The XmlSerializer cannot process classes implementing the IDictionary interface. This was partly due to schedule constraints and partly due to the fact that a hashtable does not have a counterpart in the XSD type system. The only solution is to implement a custom hashtable that does not implement the IDictionary interface.

    So I think you need to create your own version of the Dictionary for this. Check this other question.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Expanding on recent_posts_on_self below, I want to add an all_recent_posts_on_self method but I'm not
I have a problem with expanding JTree nodes. I start when use selects a
Having problem with the middle Div not expanding to the width http://acs.graphicsmayhem.com/images/middiv.jpg Ok, how
I'm extending a class and overriding a method. All I want to do is
i am having trouble with custom quick-fixes, which i want to provide in my
Background Expanding upon this question. I have a collection of points (in a three
Expanding on a question I asked earlier about how to iterate over a collection
Expanding on my previous question here , I want to know if is possible
I'm expanding a VB6 application which communicates with small embedded systems to use the
I have an expandable list view I am using in one xml file which

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.