0
我正在使用Silverlight 4和Prism 4進行開發。Prism4:從xaml創建目錄CreateFromXaml不能編譯
我也使用Unity作爲我的注入容器。
我試圖從xaml創建模塊目錄,但是我得到這個錯誤「IModuleCatalog沒有包含CreateFromXaml的定義...」。
我的代碼片斷是:
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Practices.Prism.UnityExtensions;
using Microsoft.Practices.ServiceLocation;
using Microsoft.Practices.Prism.Modularity;
using Microsoft.Practices.Prism.MefExtensions;
namespace MyModularityProject {
public class MyBootStrapper : UnityBootstrapper {
protected override DependencyObject CreateShell() {
return ServiceLocator.Current.GetInstance<Shell>();
}
protected override void InitializeShell() {
base.InitializeShell();
Application.Current.RootVisual = (UIElement)Shell;
}
protected override IModuleCatalog CreateModuleCatalog() {
// This is the isntruction that doesn't compile
return ModuleCatalog.CreateFromXaml(new
Uri("/MyProject.Silverlight;component/ModulesCatalog.xaml",
UriKind.Relative));
}
}
}
什麼可能我在這裏失去了?
您是否嘗試清理您的項目。關閉並重新打開Visual Studio?錯誤提到'*我* ModuleCatalog'。這就是'ModuleCatalog'實現的接口不是類本身。任何想法,爲什麼這可能是? –
答案是使用長篇限定的句子:Microsoft.Practices.Prism.Modularity.ModuleCatalog.CreateFromXaml。謝謝 – user1462071
@ user1462071你應該添加一個答案並接受它,而不是評論 – onof