2014-11-03 162 views
0

好吧所以我花了一天试图解决这个问题与Autofac,Moq和Moq.Contrib.Indy我一直在使用Nuget升级我的各种项目到最新版本的包括Autofac在内的东西。升级到最新版本的Autofac项目被破坏

我的项目是指以下: -

<Reference Include="Autofac, Version=3.5.0.0, Culture=neutral, PublicKeyToken=17863af14b0044da, processorArchitecture=MSIL"> 
     <SpecificVersion>False</SpecificVersion> 
     <HintPath>..\packages\Autofac.3.5.2\lib\net40\Autofac.dll</HintPath> 
    </Reference> 
    <Reference Include="Autofac.Integration.Mvc, Version=3.0.0.0, Culture=neutral, PublicKeyToken=17863af14b0044da, processorArchitecture=MSIL"> 
     <SpecificVersion>False</SpecificVersion> 
     <HintPath>..\packages\Autofac.Mvc5.3.3.3\lib\net45\Autofac.Integration.Mvc.dll</HintPath> 
    </Reference> 
    <Reference Include="AutofacContrib.CommonServiceLocator, Version=2.6.3.862, Culture=neutral, PublicKeyToken=17863af14b0044da, processorArchitecture=MSIL"> 
     <SpecificVersion>False</SpecificVersion>   
<HintPath>..\packages\Autofac.CommonServiceLocator.Indy.2.6.3.863\lib\net40\AutofacContrib.CommonServiceLocator.dll</HintPath> 
    </Reference> 

我遵循了这个问题Weird exception after updated Autofac

但是给出的建议,当我运行我的单元测试,我得到一个错误,如下所示。

SetUp : System.MissingMethodException : Method not found: 'Autofac.Builder.IRegistrationBuilder`3<!0,!1,!2> Autofac.Builder.IRegistrationBuilder`3.PropertiesAutowired(Autofac.PropertyWiringFlags)'. at Moq.Contrib.Indy.AutoMockContainer.<Create>b__0<T>(ContainerBuilder builder) at Moq.Contrib.Indy.AutoMockContainer.Update(Action`1 registration) at Moq.Contrib.Indy.AutoMockContainer.ResolveOrCreate(Action`1 registration) at Moq.Contrib.Indy.AutoMockContainer.Create() at NUnitTests.TestContext`1..ctor() in TestContext.cs: line 24 at NUnitTests.AccountsAccountLutTests..ctor() 

我已经完全去除,以从App.config中,该packages.config和.csproj的文件Autofac和起订量的所有引用的话,我已经重新添加使用的NuGet所需的参照,这样的依赖关系的正确完成。然而,似乎无论我做什么,我都会遇到运行时错误,无法尝试运行我的测试......看起来似乎感觉好像最新的Autofac已损坏?任何建议感激地收到我很想让我的测试再次工作。

还是这些东西不兼容了,我应该放弃并走向不同的方向?

问候儒略

回答

1

封装Moq.Contrib.Indy引用Autofac.CommonServiceLocator.Indy,这反过来,指定它引用Autofac 2.6.3.862。

Autofac 2.6.3很旧。 2012年6月老。自那时以来,Autofac发生了很大变化。很可能这些你所引用的“Indy”软件包没有跟上确保它们与新版Autofac正确向前兼容,这就是你看到这个问题的原因。

我猜“印”包需要实际指定不仅他们需要Autofac> = 2.6.3,但也是他们需要Autofac < 3.0.0

我会在短期内推荐恢复到您使用的旧版本的Autofac。长期来看,我建议您联系the author of those Indy packages,看看是否可以让他们更新以兼容最新的Autofac。