moq/labs

Pin castle dependency in package

JohanLarsson opened this issue · 1 comments

System.Reflection.TargetInvocationException : Exception has been thrown by the target of an invocation.
  ----> System.TypeInitializationException : The type initializer for 'Moq.Mock`1' threw an exception.
  ----> System.TypeInitializationException : The type initializer for 'Moq.Proxy.CastleProxyFactory' threw an exception.
  ----> System.IO.FileLoadException : Could not load file or assembly 'Castle.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at System.Reflection.MethodBase.Invoke(Object obj, Object[] parameters)
   at Moq.Mock.SetupAllProperties(Mock mock, Stack`1 mockedTypesStack)
   at Moq.Mock.<>c__DisplayClass72_0.<SetupAllProperties>b__0()
   at Moq.PexProtector.Invoke(Action action)
   at Moq.Mock.SetupAllProperties(Mock mock)
   at Moq.Mock`1.SetupAllProperties()
   at Moq.Mocks.<CreateMocks>d__6`1.MoveNext()
   at System.Linq.Enumerable.First[TSource](IEnumerable`1 source)
   at Moq.Linq.MockQueryable`1.Execute[TResult](Expression expression)
   at Moq.Mock.Of[T]()
   at Gu.Reactive.Tests.Reflection.PropertyPathParserTests.GetPathFromMock() in C:\Git\Gu.Reactive\Gu.Reactive.Tests\Reflection\PropertyPathParserTests.cs:line 47
--TypeInitializationException
   at Moq.Mock`1.SetupGet[TProperty](Expression`1 expression)
--TypeInitializationException
   at Moq.Proxy.CastleProxyFactory..ctor()
   at Moq.Mock`1..cctor()
--FileLoadException
   at Moq.Proxy.CastleProxyFactory..cctor()

When checking nuget the castle dependency is Castle.Core (>= 4.0.0) it should be pinned to an exact version or the assembly loading should handle never versions of castle.

kzu commented

Plz report this on the moq/moq4 repo.

This could be fixed fairly easily with an app.config with an appropriate binding redirect in the test project (xunit and I believe MSTest too). Runners should pick that up.

Thanks