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 FilesMicrosoft Molesbinmoles.exe" @"D:…objDebugMolesmoles.args"" exited with code –1007
‘System.Net.Moles.SFileWebResponse.Dispose(bool)’: no suitable method found to override [D:…objDebugMolessm.g.csproj]
Cannot call an abstract base member: ‘System.Xml.XmlReader.Close()’ [D:…objDebugMolessxm.g.csproj]
The command ""C:Program FilesMicrosoft Molesbinmoles.exe" @"D:…objDebugMolesmoles.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="">
  <Assembly Name="System.Xml" ReflectionOnly="true"/>

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