Skip to content
JHotterbeekxBannerconnect edited this page Jan 4, 2018 · 7 revisions

While using Moq you might run into some questions, we try to answer the most asked of them here.

Running a test triggers a Method not found: 'Void ...' exception

This is caused by the problem described in dotnet/standard#481, and adding the following to your .csproj file should resolve your issue:

<PropertyGroup>
  <AutoGenerateBindingRedirects>true</AutoGenerateBindingRedirects>
  <GenerateBindingRedirectsOutputType>true</GenerateBindingRedirectsOutputType>
</PropertyGroup>

The problem indeed gets triggered by System.Threading.Tasks.Extensions package (which Moq references because of ValueTask). Note that it does not target the full .NET Framework, only .NET Standard. Referencing a .NET Standard assembly from a .NET Framework project used to not work, but support for doing just that was added in .NET 4.6.1. Unfortunately, it's a pretty flaky feature. See the linked issue for details.

We are looking into this, but if you run into this issue you could use this solution to circumvent the issue. For more information see miq/moq4#566

Clone this wiki locally