This project has moved and is read-only. For the latest updates, please go here.

Could Not create string property name from string

Jan 28, 2010 at 4:37 PM

I was testing the json using BSon trying different scenerios and found a problem serializing a dictionary where the index is an object rather than a value type and get this error:

Could not create string property name from type 'Drms.Server.Oas.Persistence.Tests.DAOTests+TestClass1'.

 Is there something else I should do to get this to work.

this is the test I was trying:

 public class TestClass1
     private IDictionary<TestClass1, double> m_doublesDic2 = new Dictionary<TestClass1, double>();

     public IDictionary<TestClass1, double> DoublesDic2
            get { return m_doublesDic2; }
            set { m_doublesDic2 = value; }

TestClass1 t1 = new TestClass1();
t1.DoublesDic2.Add(new TestClass1(), 1);
t1.DoublesDic2.Add(new TestClass1(), 2);
t1.DoublesDic2.Add(new TestClass1(), 3);

JsonSerializer js = new JsonSerializer();
BsonWriter bw = new BsonWriter(ms);




Jan 31, 2010 at 5:37 AM

A property name has to be a string and that class has no TypeConverter to convert it to a string.

Jan 31, 2010 at 5:50 PM

ok , ill try puting in a type converter for it but the converter  will just run it through json to give me a string anyhow so do you think its possible for it to by default to do that. ie, it runs across a dictionary key thats doesnt have a type converter that can convert it to a string and given it needs a string, try runing it through jason to see if it can get a json string.