1. Trang chủ
  2. » Công Nghệ Thông Tin

Professional ASP.NET 3.5 in C# and Visual Basic Part 164 ppsx

10 326 0

Đang tải... (xem toàn văn)

THÔNG TIN TÀI LIỆU

Nội dung

Evjen bapp02.tex V2 - 01/28/2008 4:40pm Page 1596 Appendix B: ASP.NET Ultimate Tools Power Toys Pack Installer What’s better than a useful Visual Studio Add-in? Why, an automatic installer that downloads a list of useful add-ins and lets you select them and install at once, that’s what! The Power Toys Pack Installer, shown in Figure B-12, is an open source CodePlex project that downloads a feed full of at least three dozen projects, samples, starter kits and extensions that can be selected and installed en masse. Figure B-12 The selection is cherry-picked from projects and downloads all over Microsoft. Some highlights include Microsoft. NET Interfaces for Skype and starter kits for creating your own Shareware. Developer tools include ILMerge, a utility for merging multiple .NET assemblies into a single assembly, the Internet Explorer Developer Toolbar mentioned earlier in this chapter, a Managed Stack Explorer for investigating application hangs, and XML Notepad 2007, an experimental interface for browsing and editing XML documents. There are also choice Add-Ins such as the VS Source Outliner, giving you a tree view of your project’s member and types for use as an alternative navigational method. A few tools aren’t ready for Visual Studio 2008, but I expect to see them updated, given community pressure. 1596 Evjen bapp02.tex V2 - 01/28/2008 4:40pm Page 1597 Appendix B: ASP.NET Ultimate Tools Extending ASP.NET ‘‘Oh man! :-) I have shoot into my foot myself ;-) Sorry!’’ — matz.’’ ASP.NET AJAX Control Toolkit The AJAX Control Toolkit is a collaboration between Microsoft and the larger ASP.NET community. Its goal was to provide the largest collection of Web client components available. It includes excellent examples if you want to learn how to write ASP.NET Ajax yourself, and then it gives you the opportunity to give back and have your code shared within the community. There are literally dozens of controls that build on and extend the ASP.NET Ajax framework. Some of the controls are simple and provide those nice ‘‘little touches’’ such as drop shadows, rounded corners, watermarks, and animations. Others provide highly functional controls such as calendars, popups, and sliders. Complete source is available for all the controls so that they can be extended and improved by you. These controls are more than just samples; they are complete and ready to be used in your applications. There’s a complete demo site available at http://ajax.asp.net/ajaxtoolkit/ showcasing examples of each control so you can try each one to see if it meets your needs, as illustrated in Figure B-13, for example. Figure B-13 Note that there are two versions one for Visual Studio 2005 and one for Visual Studio 2008. Features that are specific to the 2008 version include ‘‘reference tags’’ for toolkit JavaScript files providing more complete JavaScript IntelliSense support within Visual Studio. 1597 Evjen bapp02.tex V2 - 01/28/2008 4:40pm Page 1598 Appendix B: ASP.NET Ultimate Tools Atif Aziz’s ELMAH — Error Logging Modules and Handlers Troubleshooting errors and unhandled exceptions in your applications can be a full-time job. Rather than writing your own custom global exception handlers every time, consider looking at the ELMAH (Error Logging Modules And Handlers) from Atif Aziz. It’s a very flexible application-wide error logging facility with pluggable extension points to the interfaces at nearly every location. You can even configure it in your application without re-compilation or even redeployment. Simply modify your web.config to include the error logging modules and handlers, and then you’ll receive a single Web page to remotely review the entire log of unhandled exceptions. ELMAH captures so much information about exceptions that it can reconstitute the original ‘‘yellow screen of death’’ that ASP.NET would have generated given an exception, even if customErrors was turned off. It’s almost like TiVo for your exceptions! Figure B-14 shows ELMAH, providing a developer’s view, including all the details you might need to debug this error. Figure B-14 Another clever feature is an RSS feed that shows the last 15 years from your log. This flexible tool is open source and the recent beta includes support for medium trust environments. You can plug in SQL Server or use an XML file to manage your error logs. I highly recommend you take the time to learn about ELMAH. 1598 Evjen bapp02.tex V2 - 01/28/2008 4:40pm Page 1599 Appendix B: ASP.NET Ultimate Tools Helicon’s ISAPI_Rewrite Users of the Apache Web server sing the praises of the power of mod_rewrite , their URL rewriting mechanism. IIS users have this available to them in the form of the ISAPI Rewrite module from Helicon. It’s incredibly fast because it’s written in pure C. It integrates nicely with ASP.NET because URLs are rewritten before ASP.NET realizes anything has happened. Because it uses regular expressions, it can initially be very frustrating due to its terse syntax. However, if you are patient, it can be an incredibly powerful tool for your tool belt. I recently discovered that there were a dozen ways to visit my blog that all lead to the same location. This was a confusing Google because it appeared that my blog had multiple addresses. I wanted not only to canonicalize my URL but also send back a 301 HTTP redirect to search indexes, thereby raising my standing within the search by appearing to have only one official URL. For example, all of these links were valid ways to reach my blog: ❑ www.hanselman.com/blog/ ❑ www.hanselman.com/blog/default.aspx ❑ www.hanselman.com/blog ❑ http://hanselman.com/blog/ ❑ http://hanselman.com/blog/default.aspx ❑ http://hanselman.com/blog ❑ www.hanselman.com/blog/Default.aspx ❑ www.computerzen.com/blog/ ❑ www.computerzen.com ❑ http://computerzen.com/blog/ ❑ http://computerzen.com/ Notice that there’s a difference between a trailing slash and no trailing slash in the eyes of a search engine. Using ISAPI Rewrite, I created this rather terse but very effective configuration file: [ISAPI_Rewrite] RewriteRule /blog/default \ .aspx http \ ://www.hanselman.com/blog/ [I,RP] RewriteCond Host: ^hanselman \ .com RewriteRule (.*) http \ ://www.hanselman.com$1 [I,RP] RewriteCond Host: ^computerzen \ .com RewriteRule (.*) http \ ://www.hanselman.com$1 [I,RP] RewriteCond Host: ^www.computerzen \ .com RewriteRule (.*) http \ ://www.hanselman.com/blog/ [I,RP] The I and RP at the end of the line indicate that this match is case insensitive and the redirect should be permanent rather than temporary. The rules that include a $1 at the end of line cause the expression to include any path after the domain name. This allows the rule to apply site-wide and provides these benefits to every single page on my site. It’s powerful and that’s worth your time. 1599 Evjen bapp02.tex V2 - 01/28/2008 4:40pm Page 1600 Appendix B: ASP.NET Ultimate Tools General Purpose Developer Tools ‘‘If you get the dirty end of the stick, sharpen it and turn it into a useful tool’’ — Colin Powell Telerik’s Online Code Converter Creating samples that should appear in both C# and Visual Basic can be very tedious without the assis- tance of something like Telerik’s CodeChanger.com. While it’s not an officially supported tool, this little application will definitely get you 80 percent of the way when converting between Visual Basic and C#. It also understands a surprising number of rather obscure syntaxes, as shown in Figure B-15, where I tried to convert an immediate if from C#’s ?: syntax to VB’s IIf syntax. It’s not only useful for the writer, and blog author, but also anyone who’s trying to switch projects between the two languages. Figure B-15 1600 Evjen bapp02.tex V2 - 01/28/2008 4:40pm Page 1601 Appendix B: ASP.NET Ultimate Tools WinMerge and Differencing Tools Everyone has their favorite merge tool. Whether yours is WinMerge (Figure B-16), or Beyond Compare, or the old standby WinDiff, just make sure that you have one in your list of tools that you’re very famil- iar with. When managing large numbers of changes across large numbers of individuals on software development teams, a good merge tool can help you untangle even the most complicated conflicting checkins. Figure B-16 A number of different plug-ins are available for WinMerge that extend its functionality to include com- parison of Word and Excel documents and XML files. Other highly recommended merge tools include Beyond Compare from Scooter Software and DiffMerge from SourceGear. Each of these three tools integrates with Windows Explorer, so the comparing files are as easy as a right-click. 1601 Evjen bapp02.tex V2 - 01/28/2008 4:40pm Page 1602 Appendix B: ASP.NET Ultimate Tools Reflector If you’re not using Reflector, your .NET developer experience is lesser for it. Reflector is an object browser, decompiler, help system, powerful plug-in host, and incredible learning tool. This tiny util- ity from Microsoft developer Lutz Roeder is consistently listed as the number one most indispensable tool available to the .NET developer after Visual Studio. Reflector is amazing because it not only gives you a representation of the programmer’s intent by trans- forming IL back into C# or VB, but it includes analysis tools that help you visualize dependencies between methods in the .NET Base Class Library and within your code or any third party code. In Figure B-17, you can see not only a C# representation of the code inside System. RolePrincipal, but more importantly the methods that use it within the framework. You can continue on as deep as you want within the theoretical call stack. Figure B-17 While Reflector’s decompilation abilities may become less useful with the release of the Base Class Library source code under the Microsoft Reference License, its abilities as an object browser and its vibrant plug-in community will keep this tool on the top shelf for years to come. 1602 Evjen bapp02.tex V2 - 01/28/2008 4:40pm Page 1603 Appendix B: ASP.NET Ultimate Tools CR_Documentor CR_Documentor (Figure B-18) is another free plug-in that uses the DxCore extension technology from DevExpress. This tool is a collaboration between developer Travis Illig and Reflector author Lutz Roeder. Figure B-18 This add-on allows you to see a preview of your XML document comments in real time as you edit them within your source code in Visual Studio. CR_Documentor lets you choose your level of compliance including support for the now-defunct-but- still-useful NDoc project as well as Microsoft specific tags for use with the Microsoft ‘‘Sandcastle’’ Documentation building suite of tools. CR_Documentor also includes context menu support with snippets and helpful templates making it much easier to visualize complicated documentation. XML documentation source code provides all the tools and tags needed to make MSDN-quality help. CR_Documentor provides that last missing piece in the form of excellent and accurate visualization. It’s indispensable if you intend on building compiled help files from your source code. 1603 Evjen bapp02.tex V2 - 01/28/2008 4:40pm Page 1604 Appendix B: ASP.NET Ultimate Tools Process Explorer Last, but unquestionably not least, is Process Explorer from Mark Russinovich. To call it ‘‘Task Manager on steroids’’ would not even begin to do it justice. Process Explorer puts windows itself under a micro- scope by allowing you to peer inside your active processes, their threads, and the environment to get a clearer understanding about what is actually going on. Advanced and detailed use of this tool, along with the entire SysInternals Suite of Tools, should be required for all developers. In Figure B-19, I’m looking at the properties dialog box of an application running under the Visual Studio 2008 Web Server while a debugging session in process. I can see the process tree, the DLLs loaded into the Web server’s process, their versions, and their paths, making this an excellent tool for debugging assembly loading and versioning issues. Figure B-19 1604 Evjen bapp02.tex V2 - 01/28/2008 4:40pm Page 1605 Appendix B: ASP.NET Ultimate Tools Summary Having the right tools can mean the difference between a week of time spent in your head against the wall versus five minutes of quick analysis in debugging. The right tool can mean the difference between a tedious and keyboard-heavy code slogging or refactoring session that is actually pleasant. I encourage you to try each of the tools listed here as well as to explore the ecosystem of available tools to find those that make your development experience not just more productive but more enjoyable. 1605 . within Visual Studio. 159 7 Evjen bapp02.tex V2 - 01/28/2008 4:40pm Page 159 8 Appendix B: ASP. NET Ultimate Tools Atif Aziz’s ELMAH — Error Logging Modules and Handlers Troubleshooting errors and. pressure. 159 6 Evjen bapp02.tex V2 - 01/28/2008 4:40pm Page 159 7 Appendix B: ASP. NET Ultimate Tools Extending ASP. NET ‘‘Oh man! :-) I have shoot into my foot myself ;-) Sorry!’’ — matz.’’ ASP. NET AJAX. when converting between Visual Basic and C#. It also understands a surprising number of rather obscure syntaxes, as shown in Figure B- 15, where I tried to convert an immediate if from C# s ?: syntax

Ngày đăng: 05/07/2014, 19:20

TỪ KHÓA LIÊN QUAN