2010-05-29 4 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)); 
관련 문제