Silverlight 4.0 Prism4:从xaml创建目录CreateFromXaml不';不编译

Silverlight 4.0 Prism4:从xaml创建目录CreateFromXaml不';不编译,silverlight-4.0,unity-container,prism-4,Silverlight 4.0,Unity Container,Prism 4,我正在用Silverlight 4和Prism 4进行显影 我还使用Unity作为注射容器 我正试图从xaml创建模块目录,但出现以下错误“IModuleCatalog不包含CreateFromXaml的定义” 我的代码片段是: using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Animation; using System.Windows.Shapes; using Micros

我正在用Silverlight 4和Prism 4进行显影

我还使用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));
        }
    }
}
使用System.Windows.Input;
使用System.Windows.Media;
使用System.Windows.Media.Animation;
使用System.Windows.Shapes;
使用Microsoft.Practices.Prism.UnityExtensions;
使用Microsoft.Practices.ServiceLocation;
使用Microsoft.Practices.Prism.Modularity;
使用Microsoft.Practices.Prism.MefExtensions;
名称空间MyModularityProject{
公共类MyBootStrapper:UnityBootstrapper{
受保护的覆盖依赖对象CreateShell(){
返回ServiceLocator.Current.GetInstance();
}
受保护的覆盖无效初始值设置Shell(){
base.InitializeShell();
Application.Current.RootVisual=(UIElement)Shell;
}
受保护的覆盖IModuleCatalog CreateModuleCatalog(){
//这是不可编译的ISonstruction
返回ModuleCatalog.CreateFromXaml(新
Uri(“/MyProject.Silverlight;component/ModulesCatalog.xaml”,
乌里金(亲属);
}
}
}

这里可能缺少什么?

需要将完整路径添加到ModuleCatalog类型的原因是UnityBootTrapper继承的Bootstrapper基类中有一个ModuleCatalog属性。如果不限定名称,则实际上是在对返回IModuleCatalog的属性调用访问器。接口定义不包括此函数

需要将完整路径添加到ModuleCatalog类型的原因是UnityBootTrapper继承的引导程序基类中存在ModuleCatalog属性。如果不限定名称,则实际上是在对返回IModuleCatalog的属性调用访问器。接口定义不包括此函数

你是否试图清理你的项目。是否关闭并重新打开Visual Studio?该错误涉及
*I*ModuleCatalog
。这是由
ModuleCatalog
实现的接口,而不是类本身。知道为什么会这样吗?答案是使用一个很长的限定句:Microsoft.Practices.Prism.Modularity.ModuleCatalog.CreateFromXaml。感谢you@user1462071您应该添加一个答案并接受它,而不是您试图清理项目的注释。是否关闭并重新打开Visual Studio?该错误涉及
*I*ModuleCatalog
。这是由
ModuleCatalog
实现的接口,而不是类本身。知道为什么会这样吗?答案是使用一个很长的限定句:Microsoft.Practices.Prism.Modularity.ModuleCatalog.CreateFromXaml。感谢you@user1462071你应该添加答案并接受它,而不是评论