gpt4 book ai didi

.net - 如何调试asp.net mvc 4 源代码?

转载 作者:行者123 更新时间:2023-12-03 22:36:11 28 4
gpt4 key购买 nike

我从这里下载最新的源代码:http://aspnetwebstack.codeplex.com/SourceControl/list/changesets

1) 将 system.web.mvc 项目添加到我的解决方案中,包括 system.web.mvc 项目所依赖的其他项目。

https://public.blu.livefilestore.com/y1pWkk8-pYVhCxrqVp3WTurqXOI290cw7uGMfrKYoVDARFINGaaYgENPsoj_U1ukH3plg9O29-YiDkxBuSxMv8JWg/1%201.jpg?psid=1

2)将“CollaborativeDesign.WebUI”、“CollaborativeDesign.Domain”、“CollaborativeDesign.UnitTest”项目中system.web.mvc程序集的引用从GAC一改为system.web.mvc项目。

https://public.blu.livefilestore.com/y1phd1RsSEDGBZU_w6ke0NNw19sa51cXXsYTPB05yhKiNYPq_Hr1kdllejvrxMdDjGBHR0H94GOglRvt-1MUAA7ng/2.jpg?psid=1

3) 更改根 Web.config 文件如下所示:

https://public.blu.livefilestore.com/y1pKu-Q0K765sayJazkM8OLmC-r-Kj2lkkq5fs6M0Kl6YwN5CtVvKYFzrmdkyj8oMIboOWPpBnDnt5mabIoAZuhTw/3.jpg?psid=1

https://public.blu.livefilestore.com/y1pi3d9IWgFkCpnornqTMs4OQTBdC2IDL3YL2A51DFdjYE4wFcn_-NYKMjLYtl2PjCYedngHZ5sSblOlFj-zIrnUg/4.jpg?psid=1

4)修改“View”目录下的Web.config文件如下图所示:

<!--<pages validateRequest="false" pageParserFilterType="System.Web.Mvc.ViewTypeParserFilter, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" pageBaseType="System.Web.Mvc.ViewPage, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" userControlBaseType="System.Web.Mvc.ViewUserControl, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<controls>
<add assembly="System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" namespace="System.Web.Mvc" tagPrefix="mvc" />
</controls>
</pages>-->
<pages validateRequest="false" pageParserFilterType="System.Web.Mvc.ViewTypeParserFilter, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=null" pageBaseType="System.Web.Mvc.ViewPage, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=null" userControlBaseType="System.Web.Mvc.ViewUserControl, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=null">
<controls>
<add assembly="System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=null" namespace="System.Web.Mvc" tagPrefix="mvc" />
</controls>
</pages>

5)当我运行项目时,看起来仍然使用GAC system.web.mvc.dll,因为当我在“system.web.mvc”项目中的“Controller.cs”文件中设置断点时,它表明它没有为文档加载任何符号,我也无法进入mvc源代码的方法。

https://public.blu.livefilestore.com/y1pgt_xkjJLw3bPFj6R6z2EAyqxCYC4Yk0cfYUe4RCUEkYT9EQPb56CZ1qKVI8_zGBoRe5VcFcRjmNjnc24hFmyDw/5.jpg?psid=1

如何调试源代码?
我怎么知道加载的 system.web.mvc.dll 是 GAC 的还是我本地的?

最佳答案

根据@Rick.Anderson-at-Microsoft.com 的评论,我通过执行以下附加步骤解决了这个问题:

1> 在可视化命令行中运行“sn.exe -Vr *,31BF3856AD364E35”

2> 将 System.Web.Mvc 项目中 CommonAssemblyInfo.cs 中的“AssemblyVersion”和“AssemblyFileVersion”从“4.0.0.0”改为“4.0.0.1”。重建项目。

#if ASPNETMVC
[assembly: AssemblyVersion("4.0.0.1")]
[assembly: AssemblyFileVersion("4.0.0.1")]
[assembly: AssemblyProduct("Microsoft ASP.NET MVC")]
#elif ASPNETWEBPAGES

3> 更改根目录下的Web.config文件
<compilation debug="true" targetFramework="4.0">
<assemblies>
<add assembly="System.Web.Abstractions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Helpers, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Routing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Web.Mvc, Version=4.0.0.1, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<!--<add assembly="System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=null" />-->
<add assembly="System.Web.WebPages, Version=2.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"/>


<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
<assemblyIdentity name="System.Web.Helpers" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
<dependentAssembly>
<!--<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31bf3856ad364e35" />-->
<assemblyIdentity name="System.Web.Mvc" publicKeyToken="31BF3856AD364E35" />
<bindingRedirect oldVersion="1.0.0.0-3.0.0.0" newVersion="4.0.0.1" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Web.WebPages" publicKeyToken="31bf3856ad364e35" />
<bindingRedirect oldVersion="1.0.0.0" newVersion="2.0.0.0" />
</dependentAssembly>
</assemblyBinding>

4> 更改 View 目录中的 Web.config 文件
<system.web.webPages.razor>
<!--<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />-->
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=4.0.0.1, Culture=neutral, PublicKeyToken=31BF3856AD364E35" />
<pages pageBaseType="System.Web.Mvc.WebViewPage">
<namespaces>
<add namespace="System.Web.Mvc" />
<add namespace="System.Web.Mvc.Ajax" />
<add namespace="System.Web.Mvc.Html" />
<add namespace="System.Web.Routing" />
<add namespace="DevTrends.MvcDonutCaching" />
</namespaces>


<!--<pages validateRequest="false" pageParserFilterType="System.Web.Mvc.ViewTypeParserFilter, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" pageBaseType="System.Web.Mvc.ViewPage, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" userControlBaseType="System.Web.Mvc.ViewUserControl, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<controls>
<add assembly="System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" namespace="System.Web.Mvc" tagPrefix="mvc" />
</controls>
</pages>-->
<pages validateRequest="false" pageParserFilterType="System.Web.Mvc.ViewTypeParserFilter, System.Web.Mvc, Version=4.0.0.1, Culture=neutral, PublicKeyToken=31BF3856AD364E35" pageBaseType="System.Web.Mvc.ViewPage, System.Web.Mvc, Version=4.0.0.1, Culture=neutral, PublicKeyToken=31BF3856AD364E35" userControlBaseType="System.Web.Mvc.ViewUserControl, System.Web.Mvc, Version=4.0.0.1, Culture=neutral, PublicKeyToken=31BF3856AD364E35">
<controls>
<add assembly="System.Web.Mvc, Version=4.0.0.1, Culture=neutral, PublicKeyToken=31BF3856AD364E35" namespace="System.Web.Mvc" tagPrefix="mvc" />
</controls>
</pages>

5> 重新启动 Asp.net 开发服务器。好的,欣赏源代码!感谢@Rick.Anderson-at-Microsoft.com 的评论。

debug image

关于.net - 如何调试asp.net mvc 4 源代码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9952825/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com