我一個項目轉換爲棱鏡/ MEF,需要從中央數據庫棱鏡/ MEF - 當下載的模塊列表加載
下載模塊列表但是「列表下載器」實例參考設置對空,因此假設該代碼是不是在正確的地方
這裏的流動
public class Bootstrapper : MefBootstrapper {
[Import]
IMyList sync1 { get; set; }
...
protected override void ConfigureAggregateCatalog() {
**sync1.Sync(); // sync1 is null**
AggregateCatalog.Catalogs.Add(....)
}
...
}
[Export(typeof(IMyList))]
private class DBSync : IMyList {
[Import] IDBConn mydb { get; set; }
public void Sync(){
// connects to mydb and gets a list of auth modules for the current user
}
}
的概率是SYNC1爲空!爲什麼?
我知道我做錯了什麼,但是這是從頭開始我的第一個棱鏡項目,所以請去容易
問題是Bootstrapper.ConfigureModuleCatalog()中的容器爲null,其中模塊列表需要在使用Sync() – Kumar 2011-12-22 19:56:44