OrderedDictionary becomes Hashtable when exported to and imported from clixml - by Roman Kuzmin

Status : 

 


4
0
Sign in
to vote
ID 771721 Comments
Status Active Workarounds
Type Bug Repros 3
Opened 11/20/2012 5:07:07 AM
Access Restriction Public

Description

The following script shows the problem:

    # new OrderedDictionary
    $t1 = [ordered] @{p1=11; p2=22; p3=33}

    # it is OrderedDictionary
    $t1.GetType().Name

    # export
    $t1 | Export-Clixml z1.clixml

    # import
    $t2 = Import-Clixml z1.clixml

    # it is not OrderedDictionary, it is Hashtable
    $t2.GetType().Name

Actual output:

    OrderedDictionary
    Hashtable

Expected output:

    OrderedDictionary
    OrderedDictionary
Sign in to post a comment.
Posted by Roman Kuzmin on 5/9/2014 at 9:19 AM
v4.0 has the same issue.
Posted by Ronald Rink on 1/26/2013 at 7:49 AM
It actually seems that the type information gets lost when importing via Import-CliXml as the exported xml file still contains the following type information: "<T>System.Collections.Specialized.OrderedDictionary</T>".