If you can't find a replacement, and you don't want to change the collection type you're using, the simplest thing may be to write a type-safe wrapper around OrderedDictionary.
It is doing the same work you're doing now, but the un-type-safe code is much more limited, just in this one class. In this class, we can rely on the backing dictionary only having TKey and TValue types in it, because it could only have been inserted from our own Add methods. In the rest of your application, you can treat this as a type-safe collection.
public class OrderedDictionary<TKey, TValue> : IDictionary<TKey, TValue> {
private OrderedDictionary backing = new OrderedDictionary();
// for each IDictionary<TKey, TValue> method, simply call that method in
// OrderedDictionary, performing the casts manually. Also duplicate any of
// the index-based methods from OrderedDictionary that you need.
void Add(TKey key, TValue value)
{
this.backing.Add(key, value);
}
bool TryGetValue(TKey key, out TValue value)
{
object objValue;
bool result = this.backing.TryGetValue(key, out objValue);
value = (TValue)objValue;
return result;
}
TValue this[TKey key]
{
get
{
return (TValue)this.backing[key];
}
set
{
this.backing[key] = value;
}
}
}