Question

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?

Was it helpful?

Solution

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>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top