1

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));
        }
    }
}

ここで何が欠けているのでしょうか?

4

1 に答える 1

1

ModuleCatalog 型にフル パスを追加する必要がある理由は、UnityBootstrapper が継承する Bootstrapper 基本クラス内に ModuleCatalog プロパティがあるためです。名前を修飾しない場合は、基本的に、IModuleCatalog を返すプロパティのアクセサーを呼び出しています。インターフェイス定義には、この関数は含まれていません。

于 2016-04-06T16:20:36.990 に答える