I'm trying Moles for the first time. When I try to add a Moles assembly on System.Windows.Forms it generates code with references to System.Collections.Generic.IReadOnlyCollection and IReadOnlyList which doesn't compile because they are only in .NET Framework 4.5 and my projects are all 4.0 in VS2010. I've set the assembly references to specific versions but that didn't help. Any ideas?

有帮助吗?

解决方案

If you are running Moles in Visual Studio 2012, you will need to explicitly exclude certain assemblies and types.

Here's what works for me:

<Assembly Name="System.Windows.Forms" ReflectionOnly="true"/>
<StubGeneration>
    <Types>
        <Clear />
        <Add FullName="Your.Type.Full.Name!" />
    </Types>
</StubGeneration>
<MoleGeneration>
    <Types>
        <Clear />
        <Add FullName="Your.Type.Full.Name!" />
    </Types>
</MoleGeneration>
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top