代码之家  ›  专栏  ›  技术社区  ›  David Neale

类型xxx中的方法“generate”没有更新的实现-s arp

  •  1
  • David Neale  · 技术社区  · 15 年前

    我一直在使用S arp,并更新了 Generate 方法在 AutoPersistenceModelGenerator 与Fluent NHibernate 1.1合作。我还将其程序集名称从myproject.data更改为myproject.infrastructure,我不确定是哪个导致了此问题:

        public AutoPersistenceModel Generate()
        {
            return AutoMap.Assemblies(new myProjectMappingConfiguration(),
                                      typeof (MyClass).Assembly)
                .Conventions.Setup(GetConventions())
                .IgnoreBase<Entity>()
                .IgnoreBase(typeof (EntityWithTypedId<>))
                .UseOverridesFromAssemblyOf<AutoPersistenceModelGenerator>();
        }
    

    在城堡温莎登记包含上述方法的大会…

            container.Register(
                AllTypes.Pick()
                .FromAssemblyNamed("MyProject.Infrastructure")
                .WithService.FirstNonGenericCoreInterface("MyProject.Core"));
    

    …它抛出了这个异常:

    程序集“myproject.infrastructure,version=1.0.0.0,culture=neutral,publicKeyToken=null”中类型“myproject.infrastructure.nhibernatemaps.autopersistenceModelGenerator”中的方法“generate”没有实现。

    我已经彻底清理了项目并重新构建了它,但是错误仍然在发生。

    我不知道这会不会有什么不同,但是上面的方法实际上是在global.asax中直接调用的:

        private void InitializeNHibernateSession()
        {
            var cfg = NHibernateSession.Init(
                webSessionStorage,
                new string[] { Server.MapPath("~/bin/MyProject.Infrastructure.dll") },
                new AutoPersistenceModelGenerator().Generate(),
                Server.MapPath("~/NHibernate.config"));
         }
    

    我试过取消国际奥委会的注册,但同样的错误也会出现在这个方法上:

        public void Initialize(Action initMethod)
        {
            if (!this.NHibernateSessionIsLoaded)
            {
                lock (syncLock)
                {
                    if (!this.NHibernateSessionIsLoaded)
                    {
                        initMethod();
                        this.NHibernateSessionIsLoaded = true;
                    }
                }
            }
        }
    

    更新

    我重新创建了我的项目,并再次取消了相同的过程——当我将fluent nhibernate从1.0更新到1.1时,就会出现错误。有什么想法吗?

    2 回复  |  直到 14 年前
        1
  •  3
  •   David Neale    15 年前

    我认为这是由于部分S arp体系结构组件引用了旧的流畅的nhibernate版本造成的。

    我将S_arp程序集更新为1.6(现在使用的是fnh 1.1),现在可以工作了。

        2
  •  2
  •   mockobject    14 年前

    我遇到了同样的问题,但还没有准备好更新我的Sharparch版本,我也在使用FluentHibernate的2.0.0.0版本。您可以通过在app.config或web.config中使用程序集绑定重定向来解决此问题。这样地:

        <runtime>
        <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
            <dependentAssembly>
                <assemblyIdentity name="FluentNhibernate" publicKeyToken="8aa435e3cb308880" culture="neutral"/>
                <bindingRedirect oldVersion="0.0.0.0-65535.65535.65535.65535" newVersion="2.0.0.0"/>
            </dependentAssembly>
        </assemblyBinding>
    </runtime>
    
    推荐文章