List<T>
リフレクションによって1 次元Int32
配列をインスタンス化しています。次を使用してリストをインスタンス化すると:
Type typeInt = typeof(System.Int32);
Type typeIntArray = typeInt.MakeArrayType(1);
Type typeListGeneric = typeof(System.Collections.Generic.List<>);
Type typeList = typeListGeneric.MakeGenericType(new Type[] { typeIntArray, });
object instance = typeList.GetConstructor(Type.EmptyTypes).Invoke(null);
リスト自体にこの奇妙な動作が見られます。
リフレクションを介してインターフェイスすると、正常に動作するように見えますが、実際の型にキャストしようとすると:
List<int[]> list = (List<int[]>)instance;
私はこの例外を受け取ります:
タイプ 'System.Collections.Generic.List`1[System.Int32[*]]' のオブジェクトをタイプ 'System.Collections.Generic.List`1[System.Int32[]]' にキャストできません。
これを引き起こしている可能性のあるもの、またはそれを解決する方法はありますか? 私は .net 4.0 の Visual Studio 2010 Express で作業しています。