2010-05-29 183 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)); 
相關問題