Interview on Debugging

David Giard posted his interview with me for his show, Technology and Friends, talking about debugging and WinDBG.

Posted: Monday, October 05, 2009 10:06:00 AM (Eastern Standard Time, UTC-05:00)  #    Comments - Trackback
Speaking | Tools | Visual Studio

More Debugging Links

As a follow up to my last post, I found more debugging links:

Posted: Tuesday, September 29, 2009 10:55:00 AM (Eastern Standard Time, UTC-05:00)  #    Comments - Trackback
Tools | Visual Studio

Creating an Extraction Rule for VSTS 2008 Web Tests

Extraction rules are essentially for finding data in the HTTP response and placing it in the output context of the web test. There are a few built-in tests, but they mostly focus on the HTML tags themselves and the attributes. In my case I really needed the data between span tags. I think this could probably be done with the existing rules and some regular expressions, but I couldn’t resist the chance to write some code and learn something new.

All you need to do is place the class file in the Test Project and compile it. The rule automatically becomes available to the tests in the project.  Here is my class that finds a span for a given ClientId. It overrides the Execute method of the ExtractionRule base class and attempts to find a span for the given ID. If the span is found, it parses the HTML string to find the content of the span tag.

namespace WebTestDemo

{

    [System.ComponentModel.DisplayName("Span Extractor")]

    public class ExtractSpan : ExtractionRule

    {

        // The name of the desired input field

        private string nameValue;

        public string ClientId

        {

            get { return nameValue; }

            set { nameValue = value; }

        }

 

        public override void Extract(object sender, ExtractionEventArgs e)

        {

            string[] tagTypeFilter = new string[] { "span" };

 

            //Fail the test if nothing is found (this may need to be modified)

            e.Success = false;

 

            if (e.Response.HtmlDocument != null && e.Response.IsHtml)

            {

                try

                {

                    //Find the span tag based on ID. Exception if none found

                    HtmlTag result = e.Response.HtmlDocument.GetFilteredHtmlTags(tagTypeFilter).First(t => string.Equals(t.GetAttributeValueAsString("ID"), this.nameValue, StringComparison.OrdinalIgnoreCase));

 

                    //The span was found (no exception), now find the data

 

                    //Get the location of the ID in the span tag

                    int startPosition = e.Response.BodyString.IndexOf(this.nameValue);

 

                    //Find the position of the data immediately following the closing angle bracket of the span,

                    //  accounting for the > character as well

                    startPosition = e.Response.BodyString.IndexOf(">", startPosition) + 1;

 

                    //Get the position of the closing tag for the span

                    int endPosition = e.Response.BodyString.IndexOf("</span>", startPosition);

 

                    //Fetch the content

                    string content = e.Response.BodyString.Substring(startPosition, endPosition - startPosition);

 

                    //Add the value to the context output. This could just as easily go to a file or a DB

                    // this step is not necessary for the extraction to succeed

                    e.WebTest.Context.Add(this.ContextParameterName, content);

 

                    //Mark the extraction as successful

                    e.Success = true;

                }

                catch (Exception)

                {

                    e.Success = false;

                    e.WebTest.Context.Add(this.ContextParameterName, string.Format("span tag id={0} not found", this.nameValue));

                }

            }

        }

    }

}

Now that I have the class, I need to wire it up to a URL in a web test. Right-click the URL and choose Add Extraction Rule…

AddRuleToTest[1]

I need to set two properties:

  1. Context Parameter Name. This comes from the base ExtractionRule class, and is the name for the data that ends up in the output.
  2. ClientId. This is a custom property from my class. It is the ClientId of the rendered control in the HTML output. The class finds the span with this name and returns the data.

Now when I run the test, if the ClientId I specified was found, it shows up in the Context output after running the test. The Context Parameter Name was “SpanData” in this case:

ExtractionRuleResults[1]

This could be made more robust by not coding specifically for spans. Certainly there could be issues if the tag ID is used more than once or if there is significant nesting of spans within the tag you are trying to find. This code is intended to prove out the concept, it could certainly be made stronger.

One thing I want to mention is that all the code samples I have run across (MSDN included) show the RuleName property as the way to display the extraction rule name in the Visual Studio UI. But under compilation this property comes up as obsolete. I found the answer on Ed Glas’s blog. The obsolete message mentioned using attributes, but this info was not discoverable, so I was quite grateful for that posting to get the syntax correct.

Helpful Links

Must Read VSTS - Testing Related Blogs and Introductory Articles

How to: Create a Custom Extraction Rule

Custom Extraction Rule and Generating a Code Test from VSTS

Posted: Wednesday, August 26, 2009 8:29:00 PM (Eastern Standard Time, UTC-05:00)  #    Comments - Trackback
.Net 3.5 | Performance | Visual Studio | VSTS

ASP.NET 2.0 and Global.asax: What not to do

I deployed a site today that has some code in the Global.asax event handlers. I let Visual Studio 2008 add the file to my project when I created it, and it put the code directly in the file inside <script runat="server"> tags. I went with it. So when I deployed the file, none of the events fired. Ever. The lesson is: Don't put your code in the global.asax file. Apparently this problem is by design. There is a vague KB Article on this problem, but the solutions aren't all that helpful, I didn't want to pre-compile, and the first solution made no sense at all. A little searching and I found one good solution: put a class that inherits HttpApplication in the App_Code folder as described here. What I don't understand is why Visual Studio adds the file that way if it isn't going to work on an xcopy deployment. Microsoft seems to go out of their way to protect us from ourselves so often that I am surprised the IDE does something intentionally that won't work.

Posted: Wednesday, February 06, 2008 3:57:21 PM (Eastern Standard Time, UTC-05:00)  #    Comments - Trackback
ASP.NET | Visual Studio

Links for VSTS Database Professional Edition

Resources

Team Site
http://msdn2.microsoft.com/en-us/teamsystem/aa718764.aspx

Product Forum
http://forums.microsoft.com/msdn/showforum.aspx?forumid=725&siteid=1

Good Blogs
http://blogs.msdn.com/camerons
http://blogs.msdn.com/sachinre

 

Downloads

Service Release 1
http://support.microsoft.com/kb/936612/

PowerTools
http://go.microsoft.com/fwlink/?LinkId=88852

Posted: Tuesday, September 25, 2007 5:00:06 PM (Eastern Standard Time, UTC-05:00)  #    Comments - Trackback
Visual Studio | VSTS

WSOD - White Screen of Death in Winforms Designer

I've seen it many times in the past, now it has a name
Posted: Wednesday, January 17, 2007 6:38:07 PM (Eastern Standard Time, UTC-05:00)  #    Comments - Trackback
Visual Studio | Winforms

CopySourceAsHTML Clipboard Access Error (Blame the VPC)

I kept getting an error when trying to use CopySourceAsHTML in Visual Studio 2005. The error was that CopySourceAsHTML was unable to access the clipboard. Turns out the problem is when using it in a VPC, and the answer is here.
Posted: Monday, January 15, 2007 10:11:51 PM (Eastern Standard Time, UTC-05:00)  #    Comments - Trackback
Strange Problems | Visual Studio

Vista and Visual Studio 2003 - Not Supported

Now that Vista has gone RTM, lots of us are trying to decide when to upgrade. Here is something I have not seen much mention of:

Visual Studio 2003 is not supported in Vista.

This is going to hold back adoption on my work machine. I'm a consultant, I have to do work on whatever platform the client is using, which unfortunately is VS 2003 sometimes. Is VS 2003 going to be relegated to life in a virtual machine from now on?

Posted: Thursday, November 09, 2006 7:42:56 PM (Eastern Standard Time, UTC-05:00)  #    Comments - Trackback
Visual Studio

Vista and Visual Studio 2003 - Not Supported

Now that Vista has gone RTM, lots of us are trying to decide when to upgrade. Here is something I have not seen much mention of:

Visual Studio 2003 is not supported in Vista.

This is going to hold back adoption on my work machine. I'm a consultant, I have to do work on whatever platform the client is using, which unfortunately is VS 2003 sometimes. Is VS 2003 going to be relegated to life in a virtual machine from now on?

Posted: Thursday, November 09, 2006 7:42:52 PM (Eastern Standard Time, UTC-05:00)  #    Comments - Trackback
Visual Studio

A List of Visual Studio 2005 Hotfixes

A Google search of hotfixes.
Posted: Thursday, August 24, 2006 8:33:33 PM (Eastern Standard Time, UTC-05:00)  #    Comments - Trackback
Visual Studio

A List of Visual Studio 2005 Hotfixes

A Google search of hotfixes.
Posted: Thursday, August 24, 2006 8:33:27 PM (Eastern Standard Time, UTC-05:00)  #    Comments - Trackback
Visual Studio

Speaking at the Visual Studio 2005 Experience on July 28th

I will be presenting sessions at the Speaking at the Visual Studio 2005 Experience on July 28th. My sessions will be on Visual Studio 2005 – New Features inside the Microsoft Across America truck. There are still spots available for some of the sessions that day. Sign up before it is too late!
Posted: Monday, July 10, 2006 5:51:46 PM (Eastern Standard Time, UTC-05:00)  #    Comments - Trackback
Speaking | Visual Studio

The Clipboard Ring Rules!

Checking amongst the group of developers I work with, no one knew this trick. I read about it yesterday here. The feature is called the Clipboard Ring, and it is in both Visual Studio 2005 and 2003. Using Ctrl+Shift+V lets you cycle through the last 10 items you have placed on the clipboard. The command is also found in the Edit Menu in and in the Toolbox in VS2003.
Posted: Friday, February 10, 2006 4:52:20 PM (Eastern Standard Time, UTC-05:00)  #    Comments - Trackback
Visual Studio

SharePoint Web Part Template for Visual Studio Install Problem

I tried to install the SharePoint web part templates today and got this error:

"Visual Studio .NET must be installed before you can install the Web Part Templates for Visual Studio .NET."

But of course, Visual Studio is installed. I found two answers to the problem on the Usenet:

Add Missing Registry Keys

Reinstall Visual Studio

Along the way I also discovered that you must either have the Microsoft.SharePoint.dll on your machine or on a share you can access in order for the install to proceed.

Posted: Thursday, September 09, 2004 6:22:56 PM (Eastern Standard Time, UTC-05:00)  #    Comments - Trackback
SharePoint | Visual Studio

Visual Studio Hampers VB.Net Developers

At the Great Lakes Area .Net users Group meeting last night, during his excellent ASP.Net tips and trick presentation, Jason Beres let us in on a dirty little trick that Visual Studio plays on VB.Net developers (not C# developers though). By default, the editor hides “advanced” properties and methods in the Intellisense.

This setting can be found in the Options dialog box. Tools Menu -> Options -> Text Editor -> Basic:

>

By default, Hide Advanced Members is checked. I guess the designers were trying to keep VB.Net “friendly” by hiding the complexity? How many times have you as a developer used the Intellisense to explore the options on an object? If you have, you were being shorted.

Posted: Thursday, June 17, 2004 1:18:24 PM (Eastern Standard Time, UTC-05:00)  #    Comments - Trackback
Visual Studio

VBCommenter

After a little consternation, got VBCommenter PowerToy working today. Had a problem after installing that was solved on their message board.

It seems to be very useful, but really slows down compiles (of course I already need more RAM so this doesn't help). Looks like I'll have to let it build XML files separate from regular compiles.

Now I need to get up to speed on XSLT to turn those XML files into something readable for non-techies. My project is getting a new person to help write documentation and I am sure the info I generate with this tool will help her out significantly.

Posted: Monday, April 26, 2004 5:44:06 PM (Eastern Standard Time, UTC-05:00)  #    Comments - Trackback
.Net 1.1 | Visual Studio