2010-05-29 144 views
0

我正在创建Silverlight应用程序运行时的动态类型的通用集合。我的代码:无法加载文件或程序集

Type listType = 
    Type.GetType("System.Collections.ObjectModel.ObservableCollection`1[[" 
       + type.AssemblyQualifiedName 
       + "]], System.Windows, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e", 
       true); 

typeType类型的变量。该类型正在运行时创建。在该代码行我有错误:

Could not load file or assembly ', Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. The system cannot find the file specified.

我该如何解决该错误?

回答

1

使用MakeGenericType代替:

Activator.CreateInstance(typeof(ObservableCollection<>).MakeGenericType(type)); 
相关问题