Reputation: 11
There are compiling errors when generating moles for .NET4 System.dll (build 4.0.30310.261) and System.Xml.Dll(build 4.0.30319.233). The errors for System.Dll are:
m.g.cs(251449,33): error CS0115: 'System.Net.Moles.SFileWebResponse.Dispose(bool)': no suitable method found to override [c:\jin\moles\tmp\s\m.g.csproj]
m.g.cs(251650,30): error CS0115: 'System.Net.Moles.SFileWebResponse.SupportsHeaders': no suitable method found to override [c:\jin\moles\tmp\s\m.g.csproj]
m.g.cs(255339,33): error CS0115: 'System.Net.Moles.SHttpWebResponse.Dispose(bool)': no suitable method found to override [c:\jin\moles\tmp\s\m.g.csproj]
m.g.cs(255540,30): error CS0115: 'System.Net.Moles.SHttpWebResponse.SupportsHeaders': no suitable method found to override [c:\jin\moles\tmp\s\m.g.csproj]
m.g.cs(303198,33): error CS0115: 'System.Net.Moles.SWebResponse.Dispose(bool)': no suitable method found to override [c:\jin\moles\tmp\s\m.g.csproj]
m.g.cs(303399,30): error CS0115: 'System.Net.Moles.SWebResponse.SupportsHeaders': no suitable method found to override [c:\jin\moles\tmp\s\m.g.csproj]
Done Building Project "c:\jin\moles\tmp\s\m.g.csproj" (default targets) -- FAILED.
The errors for System.Xml.Dll are:
m.g.cs(113977,17): error CS0205: Cannot call an abstract base member: 'System.Xml.XmlReader.Close()' [c:\jin\moles\tmp\s\m.g.csproj]
m.g.cs(116149,21): error CS0205: Cannot call an abstract base member: 'System.Xml.XmlResolver.Credentials.set' [c:\jin\moles\tmp\s\m.g.csproj]
m.g.cs(130559,17): error CS0205: Cannot call an abstract base member: 'System.Xml.XmlWriter.Close()' [c:\jin\moles\tmp\s\m.g.csproj]
I'm using Moles 0.94 with VS2010. The errors only happen for newer version of the two DLLs, after .NET 4 service pack is installed. Moles are generated fine for version 4.0.30319.1 of the two DLL, before .NET 4 service packs.
It seems the code generated by Moles is not compatible with latest .NET4 assemblies.
Upvotes: 1
Views: 1245
Reputation: 10602
See these questions:
Moling System.dll
http://social.msdn.microsoft.com/Forums/en/pex/thread/446669dd-1d69-4020-9174-dc259a55b4b4
Basically, update System.moles as follows:
<Moles xmlns="http://schemas.microsoft.com/moles/2010/">
<Assembly Name="System" ReflectionOnly="true"/>
</Moles>
Upvotes: 1