不能使用moles来模拟MVC框架

Mau*_*ice 5 .net asp.net-mvc moles asp.net-mvc-3

我试图为System.Web.Mvc DLL版本3生成痣,但是我收到以下错误:

 Moles : info : metadata : loading C:\TFS.as12.Projects\Project X\Main\Source\3rdPartyComponents\MVC3\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.53> moles generator 1 errors, 3 warnings

    Moles compilation FAILED - 6,18794176354816s
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" @"C:\TFS.as12.Projects\Project X\Main\Source\X.Web\X.Web.Base.Mvc.UnitTest\obj\Debug\Moles\moles.args"" exited with code -1002.
Run Code Online (Sandbox Code Playgroud)

我在微软论坛上看到了更多关于此的问题,但从来没有回答过.有没有人有办法解决吗?

Pet*_*Jr. 0

您可以尝试排除有问题的类型:

<Moles ...
   <StubGeneration ...
       <Types>
          <Remove TypeName="System.Web.Mvc.CompareAttribute" />
          <Remove TypeName="System.Web.Mvc.RemoteAttribute" />
       </Types>
   <MoleGeneration>
       <Types>
          <Remove TypeName="System.Web.Mvc.CompareAttribute" />
          <Remove TypeName="System.Web.Mvc.RemoteAttribute" />
       </Types>
   </MoleGeneration>
Run Code Online (Sandbox Code Playgroud)