2014-11-03 72 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。