2

ASP.NET2010で開発されたWebアプリケーションがあります。ASP.NETMVCでStructureMapを使用した依存性注入を使用しました。構造マップを使い始めようとしています。使っています

単純なブートストラッパーを作成しましたが、Webサイトを実行すると、次のエラーが発生します。

StructureMap.Configuration.DSL.Expressions.CreatePluginFamilyExpression`1 [System.Web.Mvc.IActionInvoker] .Use:タイプ引数'TestWebsite.Web.Controllers.Factories.InjectingActionInvoker'は、タイプパラメーター'CONCRETETYPE'の制約に違反しています。

コードブロック:

 public static void ConfigureStructureMap()
    {
        ObjectFactory.Initialize(x =>
        {
            //registry per assembly recommended
            x.AddRegistry<WebRegistry>();
            x.AddRegistry<ServiceRegistry>();
            x.AddRegistry<SHARE.Data.DataRegistry>();
        });

        //if a class needs configuring on load then this is done here. Inherit from IStartUpTask
        ObjectFactory.GetAllInstances<IStartUpTask>()
            .Where(x => x.IsEnabled).ToList()
            .ForEach(t => t.Configure());

        //This checks all is well.  Not ideal to do in application_start though cause of calls to request object....
        //ObjectFactory.AssertConfigurationIsValid();
    }


  public class WebRegistry : Registry
    {
        public WebRegistry()
        {
         For<IFormsAuthentication>    ().Use<FormsAuthenticationService>();
         For<IAuthentication>().Use<BasicMembership>();
                     Scan(x =>
            {
                x.AssemblyContainingType<IStartUpTask>();
                x.AddAllTypesOf<IStartUpTask>();
                x.WithDefaultConventions();
            });

            For<IActionInvoker>().Use<InjectingActionInvoker>();
            SetAllProperties(c =>
            {
                c.OfType<IActionInvoker>();
                c.WithAnyTypeFromNamespaceContainingType<UserService>(); //our services
                c.WithAnyTypeFromNamespaceContainingType<AdminCookies>(); //cookie services
            });

        }

誰かがこの問題について提案してもらえますか?どのように解決できますか?私は本当にそれに悩んでいて、できるだけ早くそれを解決する必要があります。どんな助けでも大歓迎です。

ありがとう

ディーパック

4

1 に答える 1

0

実行するには、次の変更を行います。

  1. Web サイトから MVC 3.0 DLL の参照を削除
  2. Web サイトに MVC 2.0 DLL の参照を追加
  3. プロジェクトを実行し、正常に動作する
于 2012-11-20T13:11:01.093 に答える