2012-04-18 44 views
2

我正在使用MVC 4(测试版),并有一些问题试图测试我写的auth属性。调试到.net源不工作对我

为了更深入地研究这一点,我试图使用调试到.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

你有pdb文件,对不对? – 2012-04-18 10:59:46

+0

嗯,我从WPI安装了mvc4,我很确定它也获得了pdb。此外,我可以从源代码中手动导航到源代码,这让我可以看到mvc4代码,所以我认为我做... – 2012-04-18 11:04:23

回答

0

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

我不认为Mvc4测试就是其中之一......

----新增---

邦德在评论中指出,如果你想踏入MVC4测试版源你必须在你的解决方案中包含mvc项目,并从那里引用它,首先删除你已经安装的GAC版本的引用

+0

哦,所以直到MS在他们的服务器上粘贴mvc4的符号,我不能调试到它?有没有一种方法可以用我自己的pdb文件做到这一点? – 2012-04-18 11:05:08

+2

是的 - 在你的解决方案中包含mvc项目并从那里引用它,首先删除你已经安装的GAC版本的引用 – Bond 2012-04-18 11:10:36