我正在使用MVC 4(测试版),并且在尝试测试我编写的auth属性时遇到了一些问题。
为了进一步研究这个问题,我正在尝试将调试用于.net框架源代码调试选项,以确切了解出现了什么问题。我已按照此处的设置说明进行操作:http://weblogs.asp.net/gunnarpeipman/archive/2010/07/04/stepping-into-asp-net-mvc-source-code-with-visual-studio-debugger.aspx
在完成所有这些之后,当我调试我的测试以查看发生了什么时,当我进入调用.net fw的代码行时,测试才会终止并给我例外我'我试图调试。为了完整起见,这是我的代码:
var controller = new MyController();
controller.SetFakeAuthenticatedControllerContext("foo"); // Set up a fake http context for the user
var actionDescriptor = new Mock<ActionDescriptor>();
actionDescriptor.SetupGet(x => x.ActionName).Returns("AddedForTest");
var context = new AuthorizationContext(controller.ControllerContext, actionDescriptor.Object);
var auth = new SamCommandAuthenticationAttribute();
auth.OnAuthorization(context); // On this line the test will just terminate
Assert.Pass(); // This line would never be called.
有谁知道为什么我无法调试到.net源代码?
答案 0 :(得分:0)
Microsoft Symbol服务器为.net框架程序集的子集提供符号。
我认为Mvc4 beta不是其中之一......
----加---
正如Bond在评论中指出的那样,如果你想进入MVC4 Beta源,你必须在你的解决方案中包含mvc项目并从那里引用它,首先删除你已经安装的GAC版本的引用< / p>