Moles 无法与 MVC3 (System.Web.Mvc.dll) 一起使用

发布于 2024-12-07 21:25:49 字数 3992 浏览 0 评论 0原文

我刚刚开始研究摩尔框架,从一开始我就没有得到很好的经验。 由于某种原因,我无法为 System.Web.Mvc.dll (v.3) 生成摩尔,

我将尝试逐步解释我的问题

  1. 在刚刚创建的空解决方案中,我添加了两个项目(Asp.Net MVC 3和测试)。
  2. 在测试项目中添加 C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 3\System.Web.Mvc.dll) 引用。
  3. 在我的测试项目中为 System.Web.Mvc.dll 添加 Moles Assemly(在 VS2010 中)。
  4. 构建项目。

在步骤 4 中,我收到以下错误,

    ------ Build started: Project: SampleMvcApplication.UnitTests, Configuration: Debug Any CPU ------
  Microsoft Moles v0.94.51023.0 - http://research.microsoft.com/moles - .NET v4.0.30319
  Copyright (c) Microsoft Corporation 2007-2010. All rights reserved.

  00:00:00.00> moles
    Moles : info : metadata : ignoring reference D:\Samples\Moles\SampleMVC\SampleMvcApplication\SampleMvcApplication.UnitTests\MolesAssemblies\System.Behaviors.dll
    Moles : info : metadata : ignoring reference D:\Samples\Moles\SampleMVC\SampleMvcApplication\SampleMvcApplication.UnitTests\MolesAssemblies\System.Moles.dll
    Moles : info : metadata : ignoring reference D:\Samples\Moles\SampleMVC\SampleMvcApplication\SampleMvcApplication.UnitTests\MolesAssemblies\System.Web.WebPages.Moles.dll
    Moles : info : configuration : diagnostic is on
    Moles : info : metadata : loading C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 3\Assemblies\System.Web.Mvc.dll
    Moles : info : compilation : output assembly name: System.Web.Mvc.Moles
Moles : warning : metadata : failed to load module System.Web.Mvc.dll:
Moles : warning : metadata : Inheritance security rules violated by type: 'System.Web.Mvc.CompareAttribute'. Derived types must either match the security accessibility of the base type or be less accessible.
Moles : warning : metadata : Inheritance security rules violated by type: 'System.Web.Mvc.RemoteAttribute'. Derived types must either match the security accessibility of the base type or be less accessible.
Moles : error : code : assembly contains no types or failed to load properly
  00:00:00.20> moles generator 1 errors, 3 warnings
C:\Program Files (x86)\Microsoft Moles\bin\Microsoft.Moles.targets(79,5): error MSB3073: The command ""C:\Program Files (x86)\Microsoft Moles\bin\moles.exe" @D:\Samples\Moles\SampleMVC\SampleMvcApplication\SampleMvcApplication.UnitTests\obj\Debug\Moles\moles.args" exited with code -1005.
------ Build started: Project: SampleMvcApplication, Configuration: Debug Any CPU ------
  Microsoft Moles v0.94.51023.0 - http://research.microsoft.com/moles - .NET v4.0.30319
  Copyright (c) Microsoft Corporation 2007-2010. All rights reserved.

  00:00:00.00> moles
    Moles : info : metadata : loading C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\Assemblies\System.Web.WebPages.dll
    Moles : info : compilation : output assembly name: System.Web.WebPages.Moles
    Moles : info : code : found 71 types
    Moles : info : code : visibility: exported or assembly(System.Web.WebPages.Moles)
    00:00:00.34> code generation
      Moles : info : code : generating code at D:\Samples\Moles\SampleMVC\SampleMvcApplication\SampleMvcApplication\obj\Debug\Moles\swwp\m.g.cs
      00:00:00.46> stubs generation
        Moles : info : code : generated 23 stub types
      00:00:00.86> moles generation
        Moles : info : code : generated 33 mole types
    00:00:01.70> compiling
      Moles : info : compilation : Moles assembly: D:\Samples\Moles\SampleMVC\SampleMvcApplication\SampleMvcApplication\MolesAssemblies\System.Web.WebPages.Moles.dll
  00:00:02.43> moles generator 0 errors, 0 warnings
  SampleMvcApplication -> D:\Samples\Moles\SampleMVC\SampleMvcApplication\SampleMvcApplication\bin\SampleMvcApplication.dll
========== Build: 1 succeeded or up-to-date, 1 failed, 0 skipped ==========

我调查了我发现的所有主题,但没有任何帮助(我什至没有找到有关此问题的一些好的答案和解释。)

这也没有帮助(解决方案排除有问题的类型) 不能使用moles来模拟MVC框架

请告知。 谢谢。

I just started investigate moles framework and I get not really good experince from start.
By some reason I can't generate moles for the System.Web.Mvc.dll (v.3)

I will try to explain my problem step-by-step

  1. In just created empty solution I adding two project's (Asp.Net MVC 3 and Test).
  2. Add C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 3\System.Web.Mvc.dll) reference in test project.
  3. Add Moles Assemly (in VS2010) for System.Web.Mvc.dll in my test project.
  4. Build project.

In step 4 I get a following error

    ------ Build started: Project: SampleMvcApplication.UnitTests, Configuration: Debug Any CPU ------
  Microsoft Moles v0.94.51023.0 - http://research.microsoft.com/moles - .NET v4.0.30319
  Copyright (c) Microsoft Corporation 2007-2010. All rights reserved.

  00:00:00.00> moles
    Moles : info : metadata : ignoring reference D:\Samples\Moles\SampleMVC\SampleMvcApplication\SampleMvcApplication.UnitTests\MolesAssemblies\System.Behaviors.dll
    Moles : info : metadata : ignoring reference D:\Samples\Moles\SampleMVC\SampleMvcApplication\SampleMvcApplication.UnitTests\MolesAssemblies\System.Moles.dll
    Moles : info : metadata : ignoring reference D:\Samples\Moles\SampleMVC\SampleMvcApplication\SampleMvcApplication.UnitTests\MolesAssemblies\System.Web.WebPages.Moles.dll
    Moles : info : configuration : diagnostic is on
    Moles : info : metadata : loading C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET MVC 3\Assemblies\System.Web.Mvc.dll
    Moles : info : compilation : output assembly name: System.Web.Mvc.Moles
Moles : warning : metadata : failed to load module System.Web.Mvc.dll:
Moles : warning : metadata : Inheritance security rules violated by type: 'System.Web.Mvc.CompareAttribute'. Derived types must either match the security accessibility of the base type or be less accessible.
Moles : warning : metadata : Inheritance security rules violated by type: 'System.Web.Mvc.RemoteAttribute'. Derived types must either match the security accessibility of the base type or be less accessible.
Moles : error : code : assembly contains no types or failed to load properly
  00:00:00.20> moles generator 1 errors, 3 warnings
C:\Program Files (x86)\Microsoft Moles\bin\Microsoft.Moles.targets(79,5): error MSB3073: The command ""C:\Program Files (x86)\Microsoft Moles\bin\moles.exe" @D:\Samples\Moles\SampleMVC\SampleMvcApplication\SampleMvcApplication.UnitTests\obj\Debug\Moles\moles.args" exited with code -1005.
------ Build started: Project: SampleMvcApplication, Configuration: Debug Any CPU ------
  Microsoft Moles v0.94.51023.0 - http://research.microsoft.com/moles - .NET v4.0.30319
  Copyright (c) Microsoft Corporation 2007-2010. All rights reserved.

  00:00:00.00> moles
    Moles : info : metadata : loading C:\Program Files (x86)\Microsoft ASP.NET\ASP.NET Web Pages\v1.0\Assemblies\System.Web.WebPages.dll
    Moles : info : compilation : output assembly name: System.Web.WebPages.Moles
    Moles : info : code : found 71 types
    Moles : info : code : visibility: exported or assembly(System.Web.WebPages.Moles)
    00:00:00.34> code generation
      Moles : info : code : generating code at D:\Samples\Moles\SampleMVC\SampleMvcApplication\SampleMvcApplication\obj\Debug\Moles\swwp\m.g.cs
      00:00:00.46> stubs generation
        Moles : info : code : generated 23 stub types
      00:00:00.86> moles generation
        Moles : info : code : generated 33 mole types
    00:00:01.70> compiling
      Moles : info : compilation : Moles assembly: D:\Samples\Moles\SampleMVC\SampleMvcApplication\SampleMvcApplication\MolesAssemblies\System.Web.WebPages.Moles.dll
  00:00:02.43> moles generator 0 errors, 0 warnings
  SampleMvcApplication -> D:\Samples\Moles\SampleMVC\SampleMvcApplication\SampleMvcApplication\bin\SampleMvcApplication.dll
========== Build: 1 succeeded or up-to-date, 1 failed, 0 skipped ==========

I investigated all topics that I found but nothing helps ( I even did't found some good answer and explanation about this problem.)

This not helps too (solution excluding problematic types)
Cannot use moles to mock the MVC framework

Please advise.
Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

岛徒 2024-12-14 21:25:49

您使用单元测试吗?如果是,请检查您的单元测试中是否有 MVC 3 dll 引用。

Are you using unit tests? If yes, check that you have MVC 3 dll reference in your unit tests.

牵强ㄟ 2024-12-14 21:25:49

您不必直接添加对 Moles 框架的引用。创建测试项目并添加对正在测试的项目的引用后,右键单击该引用并选择“添加 Moles 程序集”。这应该在测试项目的根目录中创建一个 .moles 文件。现在构建您的测试项目,一切顺利!

You shouldn't have to add a reference to the moles framework directly. After creating your test project and adding a reference to the project you're testing, right click on that reference and select Add Moles Assembly. This should create a .moles file in the root of your test project. Now build your test project and you're good to go!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文