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

前端之家收集整理的这篇文章主要介绍了如何调试asp.net mvc 4源代码?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我从这里下载最新的源代码http://aspnetwebstack.codeplex.com/SourceControl/list/changesets

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

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

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

4)在“查看”目录中更改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,PublicKeyToken=31BF3856AD364E35" userControlBaseType="System.Web.Mvc.ViewUserControl,PublicKeyToken=31BF3856AD364E35">
  <controls>
    <add assembly="System.Web.Mvc,PublicKeyToken=31BF3856AD364E35" namespace="System.Web.Mvc" tagPrefix="mvc" />
  </controls>
</pages>-->
<pages validateRequest="false" pageParserFilterType="System.Web.Mvc.ViewTypeParserFilter,PublicKeyToken=null" pageBaseType="System.Web.Mvc.ViewPage,PublicKeyToken=null" userControlBaseType="System.Web.Mvc.ViewUserControl,PublicKeyToken=null">
    <controls>
        <add assembly="System.Web.Mvc,PublicKeyToken=null" namespace="System.Web.Mvc" tagPrefix="mvc" />
    </controls>
</pages>

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

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

解决方法

通过执行@ Rick.Anderson-at-Microsoft.com的注释,我已经通过执行以下附加步骤来解决此问题:

1 GT;在Visual Command行中运行“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 GT;更改根目录中的Web.config文件

<compilation debug="true" targetFramework="4.0">
    <assemblies>
        <add assembly="System.Web.Abstractions,PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Web.Helpers,Version=2.0.0.0,PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Web.Routing,PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Web.Mvc,Version=4.0.0.1,PublicKeyToken=31BF3856AD364E35" />
        <!--<add assembly="System.Web.Mvc,PublicKeyToken=null" />-->
        <add assembly="System.Web.WebPages,PublicKeyToken=31BF3856AD364E35" />
        <add assembly="System.Data.Entity,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,PublicKeyToken=31BF3856AD364E35" />-->
<host factoryType="System.Web.Mvc.MvcWebRazorHostFactory,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,PublicKeyToken=31BF3856AD364E35">
   <controls>
     <add assembly="System.Web.Mvc,PublicKeyToken=31BF3856AD364E35" namespace="System.Web.Mvc" tagPrefix="mvc" />
   </controls>
</pages>-->
<pages validateRequest="false" pageParserFilterType="System.Web.Mvc.ViewTypeParserFilter,PublicKeyToken=31BF3856AD364E35">
    <controls>
        <add assembly="System.Web.Mvc,PublicKeyToken=31BF3856AD364E35" namespace="System.Web.Mvc" tagPrefix="mvc" />
    </controls>
</pages>

5个重新启动Asp.net开发服务器.好的,享受源代码!感谢@ Rick.Anderson-at-Microsoft.com发表评论.

原文链接:https://www.f2er.com/aspnet/250351.html

猜你在找的asp.Net相关文章