XML deserialization - cannot have child contents to be deserialized as an object

Element MyValue from namespace http://schemas.datacontract.org/2004/07/Services cannot have child contents to be deserialized as an object. Please use XmlNode[] to deserialize this pattern of XML.

 

I was playing with DataContractSerializer, and getting this strange error when performing de-serialization (turning XML back into an object of type MyClass).

[DataContract]
public class MyClass
{
    [DataMember]
    public string MyName;

    [DataMember]
    public object MyValue;
}

 

The error message actually is pretty clear about what the issue is, but English is a sucky language.  Let me highlight what the error message is really saying:

Element MyValue from namespace http://schemas.datacontract.org/2004/07/Services cannot have child contents to be deserialized as an object. Please use XmlNode[] to deserialize this pattern of XML.

Read it again:

Element MyValue cannot be deserialized as an object.

 

The deserializer was actually talking about the fact that it can't turn <MyValue>1</MyValue> back into an object of the type Object.

If you change your DataContract to

[DataContract]
public class MyClass
{
    [DataMember]
    public string MyName;

    [DataMember]
    public string MyValue;
}

 

Then the deserializer will be happy.

InfoPath 2013 uses new Online Pictures instead of Clip Art

 

The InfoPath 2013 Preview doesn't really have many new features.  But this one little one made me smile.

image

In InfoPath 2013, the Clip Art ribbon is replaced with Online Pictures.

image

For those of you wondering what was there before, in InfoPath 2010 it looked like this.  Yes it's that little button that we never used.

This dialog appears when you click it.

image

 

Searching for a victim's face...

image

 

image

 

A few things would make this even more awesome:

  • Add my commonly used Clip Arts to my skydrive, and link it up.  This probably works already, except my Office 2013 Preview isn't hooked up to my normal Microsoft Account.
  • Allow additional websites, I find iconfinder.com to be extremely good.
  • Or allow URL to be used directly in the dialog.

SharePoint - The object has been updated by another user since it was last fetched - while updating Site Columns

This is the second time I've been bitten by this error.

Exception:

The object has been updated by another user since it was last fetched

 

And both times I had forgotten why, and then panicked, then searched online, found articles talking about this, and figured it all out, only to recall in the last minute...

Hey, wait a minute, this happened before.

The story begins as soon as you are trying to update your site columns.  Either via the web UI, or via code, or via PowerShell.  And then you hit this error.

The cause:

This is most likely because you've created the site column using an invalid Schema XML, in particular, you've embedded the version field in the <Field> definition.

<Field Type="Text" DisplayName="OrganisationName" Required="FALSE" EnforceUniqueValues="FALSE" Indexed="FALSE" MaxLength="255" ID="{guid-xxx}" StaticName="OrganisationName" Name="OrganisationName" Version="1" ></Field>

 

The Version attribute could have got in via a number of means, but most likely you exported the existing Schema from somewhere and it got embedded.

 

My explanation:

When you update a site column, SharePoint expects that the version number of this site column object increments after the update.  But because you are updating the site column via Schema and forcing the version to be fixed all the time, that number doesn't increment.  SharePoint now thinks there's something really wrong.

 

The Fix:

Remove the Version attribute from the Field definition, and then redeploy that definition to the server.

<Field Type="Text" DisplayName="OrganisationName" Required="FALSE" EnforceUniqueValues="FALSE" Indexed="FALSE" MaxLength="255" ID="{guid-xxx}" StaticName="OrganisationName" Name="OrganisationName" ></Field>

Windows 8

Windows 8 is coming, and I wanted to say something to set people's expectations right.  I think it'll help people align their views and appreciate this new version, if they choose to upgrade.

Don't expect Windows 8 to be Windows 7 plus more shiny new stuff.  Windows 8 was never designed in the same sense that Windows 7 was actually just Windows Vista plus more polish.  If you install Windows 8 thinking to get a minor update, you will be shocked.

Windows 8 is actually a completely different beast.  Designed with different goals altogether.  It just happens to run Windows (Windows 7) applications.

But at its core, Windows 8 is a different thing.

 

Historically, there was a suitable analogy, Microsoft build Windows NT to be the better kernel going forward, and combined the two systems streams (95, 98, ME) and (NT, 2000) finally into the same stream from XP.  Windows 2000 was vastly different beast from Windows 95, because it was fundamentally a different system, it just happened to run the old Windows 95 apps.

SharePoint Saturday Melbourne 2012

 

I had a great time in Melbourne and presented my session on Building Custom REST services and consuming them with jQuery AJAX.  Thank you for attending my session and listen to me ranting for an hour.

 

As promised, there are a number of links:

 

There are a few things I missed:

On 2007, you can't easily deploy WCF or REST services to a 2007 installation.  But you can still use Javascript to talk to SharePoint 2007's built in WCF services.  Check:

For 2013, the WCF/REST solutions work fine.  I had a quick test and took some screenshots.

For DataService (ADO.NET / exposing Entity Framework via REST service), see the last feature in the demo project.

 

Drop me a comment if you want to ask me about anything specific and I'd love to geek out!

T: @johnnliu

E: john.liu at sharepointgurus.net