2

我正在使用 MVC 4 (beta),并且在尝试测试我编写的 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 源代码?

4

1 回答 1

0

Microsoft 符号服务器为 .net 框架程序集的子集提供符号。

我不认为 Mvc4 beta 是其中之一......

- - 添加 - -

正如 Bond 在评论中指出的那样,如果您想进入 MVC4 Beta 源,您必须在您的解决方案中包含 mvc 项目并从那里引用它,首先删除对您已安装的 GAC 版本的引用

于 2012-04-18T11:04:13.683 回答