我在其中一个单元测试项目(VS 2010单元测试)中使用(x86)版本0.94.51023.0。为了测试应用程序中的数据访问层方法,我尝试为System.Data.dll添加moles程序集,以便能够模拟SqlConnection & SqlCommand对象。当我在添加moles程序集时生成单元测试时,生成失败,包含以下错误详细信息
error CS0234: The type or namespace name 'SqlCredential' does not exist in the namespace 'System.Data.SqlClient'
error CS0234: The type or namespace name 'ApplicationIntent' does not exist in the namespace 'System.Data.SqlClient'生成输出窗口的末尾显示如下:
error MSB3073: The command ""C:\Program Files (x86)\Microsoft Moles\bin\moles.exe" @...\UnitTests\obj\Debug\Moles\moles.args" exited with code -1002.发布于 2013-03-08 05:18:14
这个问题似乎在用"C:\Windows\Microsoft.NET\Framework64\v4.0.30319".中的“4.0.30319.17929”替换"C:\Program (x86)\Reference System.Data“中的”System.Data dll“之后得到解决。看起来这个版本的dll中定义了SqlCredential类型,并且我能够成功地执行System.Data dll。
发布于 2013-12-02 12:48:14
我偶然发现了这个帖子http://feherzsolt.wordpress.com/2013/02/13/moles-and-net-4-5/,它似乎有正确的解决方案来解决Moles的问题,而Moles未能为System.* dll生成被模制的程序集。当.Net f/w4.0和4.5都安装在同一台机器上时,对于使用4.0 dlls的项目,在moles文件中添加ReflectionOnly="true“属性,可以解决构建失败问题。
https://stackoverflow.com/questions/15246418
复制相似问题