by Stian

Moles not compiling

Have you ever experienced that you get a long list of compilation errors after adding Moles Assembly on a reference? The other day I was stucked with several compile errors like:

The command ""C:\Program Files\Microsoft Moles\bin\moles.exe" @"D:\…\obj\Debug\Moles\moles.args"" exited with code –1007
‘System.Net.Moles.SFileWebResponse.Dispose(bool)’: no suitable method found to override [D:\...\obj\Debug\Moles\s\m.g.csproj]
Cannot call an abstract base member: ‘System.Xml.XmlReader.Close()’ [D:\...\obj\Debug\Moles\sx\m.g.csproj]
The command ""C:\Program Files\Microsoft Moles\bin\moles.exe" @"D:\…\obj\Debug\Moles\moles.args"" exited with code –1002

I tried to clean, rebuild, restart, re-add, redo and all the other tricks you do when you see a very unreasonable compile error in Visual Studio. The solution seem to be way more unlogical, but it works – so no questions asked at this time.

<Moles xmlns="http://schemas.microsoft.com/moles/2010/">
  <Assembly Name="System.Xml" ReflectionOnly="true"/>
</Moles>


moleThe secret seems to be to add the ReflectionOnly attribute and set it to true.

I should mention that while searching for a good explanation for this, I found little information, but it seemed that everybody affected by this was using Visual Studio 2010 SP1. Still, using this version on many other computers, this was the only time I ran into this issue. And I did so with adding Moles assembly for System.Xml 

Leave a Reply

Your email address will not be published. Required fields are marked *

*

52,292 Spam Comments Blocked so far by Spam Free Wordpress

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>