Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

System.TypeInitializationException #610

Closed
AlexeyTipunin opened this issue Mar 29, 2018 · 2 comments
Closed

System.TypeInitializationException #610

AlexeyTipunin opened this issue Mar 29, 2018 · 2 comments

Comments

@AlexeyTipunin
Copy link

AlexeyTipunin commented Mar 29, 2018

When I try to run my tests I get TypeInitializationException.

The piece of code;
var moc = new Mock<ITankBatteryUnitOfWorkProvider>(); moc.Setup(s => s.GetUnitOfWork()).Returns(() => null); <-- Here

Exception:
OneTimeSetUp: System.TypeInitializationException : Инициализатор типа "HMI.Test.Report.AbsReportJobTest" выдал исключение. ----> System.TypeInitializationException : Инициализатор типа "Moq.ProxyFactory" выдал исключение. ----> System.TypeInitializationException : Инициализатор типа "Moq.CastleProxyFactory" выдал исключение. ----> System.IO.FileLoadException : Не удалось загрузить файл или сборку "Castle.Core, Version=4.1.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc" либо одну из их зависимостей. Найденное определение манифеста сборки не соответствует ссылке на сборку. (Исключение из HRESULT: 0x80131040) ----> System.IO.FileLoadException : Не удалось загрузить файл или сборку "Castle.Core, Version=4.0.0.0, Culture=neutral, PublicKeyToken=407dd0808d44fbdc" либо одну из их зависимостей. Найденное определение манифеста сборки не соответствует ссылке на сборку. (Исключение из HRESULT: 0x80131040) Exception doesn't have a stacktrace

Moq 4.8.2
Castle.Core 4.2.1

Thank you!

@stakx
Copy link
Contributor

stakx commented Mar 29, 2018

Seeing that your exception message mentions an old assembly version for Castle Core (4.1.0.0), I'd say NuGet made a boo-boo when you updated your packages. Check your project configuration for any bad assembly version redirects. The current Castle.Core has assembly version 4.0.0.0 (correct), not 4.1.0.0 (incorrect).

If bad assembly version redirects are not the cause, please provide a minimal, self-contained repro code that reproduces this issue. Otherwise I'll close this issue in a few days.

@AlexeyTipunin
Copy link
Author

AlexeyTipunin commented Apr 2, 2018

All assembly versions are correct, it was the first thing I have checked, but last moq package update fixes the problem.
Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants