【问题标题】:Compiling error when generating moles for System.dll, System.Xml.dll in .NET4在 .NET4 中为 System.dll、System.Xml.dll 生成痣时编译错误
【发布时间】:2012-04-25 23:08:40
【问题描述】:

为 .NET4 System.dll (build 4.0.30310.261) 和 System.Xml.Dll(build 4.0.30319.233) 生成 moles 时出现编译错误。 System.Dll 的错误是:

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.

System.Xml.Dll 的错误是:

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]

我在 VS2010 中使用 Moles 0.94。只有在安装 .NET 4 服务包之后,这两个 DLL 的较新版本才会发生错误。在 .NET 4 服务包之前,两个 DLL 的 4.0.30319.1 版本可以正常生成痣。

Moles 生成的代码似乎与最新的 .NET4 程序集不兼容。

【问题讨论】:

    标签: .net-4.0 moles


    【解决方案1】:

    查看这些问题:
    Moling System.dll
    http://social.msdn.microsoft.com/Forums/en/pex/thread/446669dd-1d69-4020-9174-dc259a55b4b4

    基本上,更新 System.moles 如下:

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-03-08
      • 1970-01-01
      • 2017-01-27
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多