October 2005 Entries

Medium Trust ASP.NET Applications

If you are an ISP offering shared hosting, or you are a developer deploying your app in a shared hosting environment, then there is no doubt you want to avoid running ASP.NET applications with full trust. Full trust is the default trust level for ASP.NET. What is full trust? The runtime defines several trust levels we can use to constrain what an application can do. These trust level range from minimal trust, which is a highly restrictive level, to full trust, which has no restrictions at all. The recommended trust level for an ASP.NET application is right in the middle:...

New Microsoft Certifications

The curtain is rising on a new set of Microsoft certifications. I’m particularly interested to see how the new exams fare, as I’ve contributed some blood, some sweat, and quite a few tears in contributing content to these exams, as have many others. The value of a certification is a hotly debated topic. I think you have to examine the subject from two perspectives. From a personal perspective, I believe the value of a certification is what you make of it. When I studied for my MCSD years ago, I spent time looking at the objectives, then reading books, looking...

Debugging With Visual Studio

A basic introduction of the debugger features for those new to the F5 key. The debugger in Visual Studio 2005 is an amazing piece of software. You can debug C# and C++, Visual Basic and VBScript. Step over managed code, native code, mobile code, and T-SQL code. You can debug locally, or you can debug remotely. You can debug assemblies hosted by SQL Server, and JavaScript hosted by Internet Explorer. There is just-in-time debugging and Just My Code debugging. You can step into XML web services and into XSL transformations. The debugger has data tips, and data visualizers, breakpoints and tracepoints. You...

Thanks

Thanks to everyone who came to my debugging presentation at VSLive! in Orlando. I received some nice compliments afterwards that mean a lot to me. Thanks to Scott C. Reynolds for hanging at the exhibition dinner. Thanks to Sam Gentile and Robert Hurlbut for letting me tag along to the seafood dinner on Wednesday. Robert will be coming to the MAD Code Camp in a few weeks. Sam will be coming to my area in December to speak at the CMAP user group. Sam was recently elevated to the status of Architect MVP, so I expect him to trade in...

Debugging XSLT

Hidden in the numerous debugging features of Visual Studio 2005 is an XSLT debugger. Open an XSLT file in the IDE and the XML menu and toolbar will both appear with “Debug XSLT” options. Selecting debug will prompt you for an XML file to transform. The output appears in real time. What is amazing about the debugger is the number of classic debugger features that “just work”. You can set break points, step in, step over, and run to cursor. The locals and watch windows work, as does the call stack window (you can see which apply-templates brought you...

Bit Flipping the Binary Search Result

When I did the Atlas hands on lab weeks ago, the following piece of code jumped out at me: int index = Array.BinarySearch(        autoCompleteWordList,        prefixText,        new CaseInsensitiveComparer()    );   if (index < 0) {     index = ~index; } Why is the code doing a bitwise complement (~) on the return value of BinarySearch? My next stop was the documentation for the return value of Array.BinarySearch, which states: The index of the specified value in the specified array, if value is found. If value is not found and value is less than one or more elements in array, a negative number which is the bitwise complement of...

Using MSBuild and ILMerge to Package User Controls For Reuse

One of the advantages to ASP.NET server controls is the ability to package them into an assembly and reference them from other web applications. Server controls are relatively difficult to write but easy to reuse. User controls (ascx files), on the other hand, are relatively easy to develop, but don't like to swing with other projects. A common solution in 1.x involves setting up virtual directories. Yuck. The ASP.NET 2.0 environment is different. We have MSBuild. We have an ASP.NET compiler. Perhaps you've also noticed we have a tool by the name of ILMerge. Here is a proof of concept. Step...

Page_Load versus OnLoad

ASP.NET developers typically handle a Page object’s Load event with a Page_Load event handler. In 1.x the designer generates code inside an InitializeComponent method to explicitly wire Page_Load to the Load event. Lately, I’ve seen more than a handful of people dropping the Page_Load event handler in favor of overriding the Page OnLoad method. This appears to be happening more and more in 2.0, for a few reasons. First, for C# developers using a separate CodeFile, it’s not immediately obvious how to add any Page event handler if the event is not already present. Unlike the VB editor, there are...

If All Movies Ever Made Were Really About Software...

A Few Good ObjectsCol. Jessup: You want destructors?Kaffe: I think I’m entitled.Col. Jessup: You want destructors?Kaffe: I want deterministic finalization.Col Jessup: You can’t handle deterministic finalization! Pulp CompilersVincent: You know what they call a switch statement in VB?Jules: They don’t call it a switch statement?Vincent: No man, this is the same language that has an AndAlso operator. Jules: Then what do they call it?Vincent: They call it a Select Case. Full Metal PacketGunnery Sargent Hartman: My orders are to weed out all non-hackers who do not pack the chops to serve on my beloved accounting package software project. Do you maggots understand...

MVP Summit Pictures

Here is a sampling of pictures I took during the summit. This first photo is from Wednesday night’s dinner. Roughly 35% of the seats at my table were filled by a Scott. In this photo, Scott Hanselman is comparing mobile devices as Scott Bellware and Milan Negovan look on. Scott H does a great Jimmy Stewart. Also at the table was Bill Vaughn. Bill and I suspect we are long lost cousins – we both descend from Allen families of the Shenandoah Valley. Here is a shot of Bill Ryan, Sahil Malik, and Jonathan Cogley. Sahil is presenting at...

ASP.NET 2.0 User Controls in App_Code

Here is a tip I picked up at the MVP summit from ASP.NET team member Simon Calvert. You can place a user control file in App_Code, as long as the .ascx uses inline code. The user control will compile into the App_Code assembly. Instead of using LoadControl with a virtual path parameter, you can use the overloaded version accepting a Type parameter. As an example, here is the contents of MyUserControl.ascx. Place the file in the App_Code directory. <%@ Control Language="C#" ClassName="MyUserControl" %>   <script runat="server">     protected override void OnLoad(EventArgs e)   {     base.OnLoad(e);     Label.Text = "Bonjour!";   }      </script> <asp:Label runat="server" ID="Label" /> Here is...