Where do you go to find answers?

There are more and more sites coming online that allow you to ask questions.  So which site(s) do you use?

Traditional

These sites are more of the old way of finding out answers, you don’t really interact, just find your answer on the existing documentation that is posted:

Forums

There have been forums for a while where you can track down information that you have questions about:

Social Web 2.0

Now there is a new class of sites coming up that allow you to have a lot more control over what gets asked and what answers are given:

 

There are other sites and other types.  I’d like to hear if you use these sites or any others to get the answers to your questions.  I know there are blogs that you can use also, so feel free to list those here as well.

Posted 18 December 08 10:25 by Tom | 3 Comments   
Filed under , , , ,
Linq features to make smaller code

I have been working on some code that involves using Linq to query a database and came across something that I thought was really useful.  So here is the situation:

We have a query that we want to be able to sort in multiple ways.  This will allow the user to click on columns and sort by it.  That kind of thing.  The first way that I did this was to do something like the following:

if (sortmethod.CompareTo("date") == 0)
{
    var c = from p in db.ProductSales
            from t in db.Products
           where (t.Id == p.ProductId)
           group t by t into g
           orderby g.Count() descending
           select g;
} else {
    var c = from p in db.ProductSales
            from t in db.Products
           where (t.Id == p.ProductId)
           group t by t into g
           orderby g.Key
           select g;
}

This can get very long if you have multiple things that someone can sort by.  So after doing some digging around, I found an alternative way that you can do this which is much shorter and much easier to follow:

var c = from p in db.ProductSales
            from t in db.Products
            where (t.Id == p.ProductId)
            group t by t into g
            select g;

switch (sortmethod)
{
    case "date":
        c = c.OrderByDescending(g => g.Count());
        break;
    default:
        c = c.OrderBy(g => g.Key);
        break;
}

As you can see, this now allows us to just do the sorting based on what the user wants but the rest of the query doesn’t have to be redone.  This can save a lot of code and effort for development and testing.  Plus, you can imagine if there is a change to the database, in the first method, you would have to change the Linq query for each sort.  Where in the second method, you change it once and that is all.

Hope this is useful and happy coding.

Posted 12 December 08 09:50 by Tom | 3 Comments   
Filed under ,
What do you need to troubleshoot Azure?

Looking to the future with cloud computing, it is going to become increasingly important to have good information about what is happening with your site in order to properly maintain it.

Keeping development type of issues aside, what types of things do you think you will need in order to be able to properly troubleshoot a problem in your application once it is deployed to the cloud.

For example, when you publish your application, it will be similar to uploading today to a hoster in that:

  • No access to the server
  • Cannot get dumps of any processes
  • Cannot access perfmon logs
  • Cannot access the Event log

So given that type of situation:

  1. What are the possible problem situations that may arise?
  2. What types of information do you think you will require to find out what is going wrong with your application?
  3. Would you try to pull your application onto your development box to try to repro some of the problems that way?

Or are there any other concerns or thoughts you have around this?  I’d love to hear what you have to say.

Posted 19 November 08 06:00 by Tom | 6 Comments   
Filed under , , ,
Insides of Azure

Want to get more details about Windows Azure?  There is a really helpful video done by Channel 9 that talks about this upcoming product and how it works.

I think this gives great details about the architecture and also how you will use this and what it will be good for.  Check it out:


Dharma Shukla: Inside Live Framework

There are a bunch of other details you can find out about this product so feel free to post your favorites in the comments.

Posted 14 November 08 06:00 by Tom | 1 Comments   
Filed under , , ,
Windows Azure and you

So I have started to look at the new Windows Azure that we just announced, you can download the framework from here.  You can also read more about it at Azure Services Platform Developer Center.

As I started looking at this, the main sample I was focused on was the PersonalWebSite Sample.  It gives me a pretty good idea of how it is going to be to develop for this platform.  But I haven’t been able to fully look into what it is going to be like to troubleshoot it.  Especially from a production viewpoint.

Have you looked at this new platform yet?  What are your thoughts?

Posted 11 November 08 06:00 by Tom | 4 Comments   
Filed under , , ,
IntelliSense for jQuery

As for reported here, we now have an official IntelliSense documentation file that will allow you to get rich intellisense for jQuery from inside of Visual Studio.

When you go to download jQuery, you will see a Documentation link.  Or you can download it directly from here:
http://code.jquery.com/jquery-1.2.6-vsdoc.js

Using this file is simple, if you are inside an ASPX page, you can reference it like this:

<script src="jquery-1.2.6.js" type="text/javascript"></script>
<% if (false) { %>     <script src="jquery-1.2.6-vsdoc.js" type="text/javascript"></script>
<% } %>

The if (false) part will make sure we don’t render or execute this as a script but it will get loaded by IntelliSense.

If you are inside a javascript file, you can reference it in the normal way like:

/// <reference path="jquery-1.2.6-vsdoc.js" />

This also supports plug-ins.  So you will get IntelliSense on the as well.  Hope that those of you using jQuery can put this file to good use.

Posted 30 October 08 11:28 by Tom | 4 Comments   
Filed under , , ,
Strange callstacks

How many times have you been troubleshooting a dump or application, you look at the callstack and you see something that just doesn’t quite look right.  Chances are the problem is that you don’t have correct symbols.

For example, if you see something like this:

Vswebdesign!DllCanUnloadNow+0xb02a0
Vswebdesign!DllCanUnloadNow+0xb8ef4
Vswebdesign!DllCanUnloadNow+0xb2203
Vswebdesign!DllCanUnloadNow+0xb248f
Vswebdesign!DllCanUnloadNow+0x2c406
Vswebdesign!DllCanUnloadNow+105a89
...

That usually is pointing to this problem.  You can see that the offsets for the functions are very large.  Also, the callstack is the same function repeated over and over.  And most applications probably don’t call DllCanUnloadNow.

If you get this problem, you can try to get the correct symbols, or just understand what you are seeing here and know that you aren’t seeing the correct functions.  For most things that concern you, you should be able to get the correct symbols so that you can properly resolve your callstacks.

Posted 29 October 08 06:00 by Tom | 1 Comments   
Filed under , , ,
Web Site Stops Responding for 15-25 seconds

There are a number of reasons that a web site could have a delay (hang) that could cause problems.  I am going to talk about a common one that we see which is the CRL.

What we have seen in the past is the Crypto API’s are trying to update the Certificate Revocation List (CRL) from the internet. If the server doesn’t have permission to access the internet you get the delay while we wait for the request to time out.

The server is trying to get the certificate revocation list from one of these:

http://crl.microsoft.com/pki/crl/products/CodeSignPCA.crl
http://crl.microsoft.com/pki/crl/products/CodeSignPCA2.crl

There are a few ways to resolve this.  The callstack will look like:

0x0611b6b4 0x77e41817 kernel32!WaitForSingleObjectEx+0xac 
0x0611b70c 0x77da1bbb advapi32!BaseSetLastNTError+0x14 
0x0611b724 0x73ca57c9 cryptnet!CryptRetrieveObjectByUrlWithTimeout+0x12d 
0x0611b750 0x73ca56c8 cryptnet!CryptRetrieveObjectByUrlW+0x99 
0x0611b77c 0x73ca3392 cryptnet!RetrieveObjectByUrlValidForSubject+0x37 

This is also talked about on other blogs here and here.

The ways to resolve it:

1. Unblock access to the above URL so CRLs can be retrieved when needed. This is the *PREFERRED* approach.

2. Turn off CRL checking by creating a turnoffCRL.reg file with this as the content:

Windows Registry Editor Version 5.00
[HKEY_USERS\S-1-5-20\Software\Microsoft\Windows\
CurrentVersion\WinTrust\Trust Providers\Software Publishing] "State"=dword:00023e00

Note that this would be considered to be compromising the integrity of the .Net signed packages stuff as we would have prevented any compromised certificates from being disabled automatically.

2. Manually update the CRL, by first downloading the file from the above URL, then running this command:

certutil -addstore CA CodeSignPCA.crl
certutil -addstore CA CodeSignPCA2.crl

Please note that this approach is NOT preferred. This is due to the fact that this would be a temporary relief -- only until this downloaded CRL expires. After it expires, the server would then make another attempt to retrieve current list, which would bring this whole problem back.

In one particular case, the CodeSignPCA.crl is set to expire on 1/4/2009 -- which would give us just under 2 months before the issue re-appears.

3. Reduce the timeout for the retrieval of the CRL to a small amount via the registry key.

UPDATE

4. Use the following workarounds:

geneartePublisherEvidence=false
<GeneratePublisherEvidence> Element

This is a good recommendation to just add this to the ASPNET.CONFIG file as this way you don’t turn off the CRL system wide. 

 

You can read more about Certificate Revocation here.

One additional note: We have run into this when the module that's being validated is called validationpathmodule.dll This module came from MS05-004 security update. This update was an interim fix that was in effect until a "full update" was released. With all latest updates for ASP.NET, this module is not needed so it can be removed. That is one of the workarounds for this situation, but only applies if the culprit is validationpathmodule.dll.

Posted 28 October 08 06:00 by Tom | 2 Comments   
Filed under , ,
Creating an Auto-complete textbox

It seems that auto-complete is very popular these days with different sites.  So I wanted to show you how you can create your own Auto-complete textbox on your web sites.  There are two ways that this can be accomplished depending on what you are using and what you want to use.

Ajax control toolkit

This method is described very well on the following blog post: ASP.NET MVC Tip #37 – Create an Auto-Complete Text Field.  The best thing about this method is that you can use a webservice as the backend for what you call to get the data back.  This enables you to have a database of possible results and populate the box as the person types.  For example, if you were going to write a web site that allows someone to post a blog, you could have a Auto-Complete textbox for the tags on the post.  Pulling down the list of tags they have used in the past.

JQuery

Another way to accomplish this is to use JQuery.  With this javascript library, you can get this to work pretty easily.  To see how, check out: UI/Autocomplete on JQuery.com.  This also has some advantages, less code and easier to setup.  But would take some more to make it more powerful, like adding Ajax to make a call to the server.  But if you have a known list, this could be really nice and would be quick.

Silverlight

You can also use Silverlight to make an Auto-complete textbox.  This method is described by Nikhil on his blog here: Silverlight AutoComplete.

 

I hope this gives you some options to add this useful method to your web sites.  Feel free to post other methods here as well.

Linq – Do we need another way to access databases?

This was the question that was burning on my mind when I first heard about Linq.  I was skeptical and didn’t think it was something that we needed.  But after having started to use this new language, I have quickly become a believer.

Linq stands for language-integrated query and that is exactly what it is, it allows for rich metadata, compile-time syntax checking, static typing and IntelliSense on things that used to be imperative code.  This is not only a huge win from the error perspective, but also from the ease of use one.

For example, here is a sample query which includes populating an array to store the data:

using System;
using System.Linq;
using System.Collections.Generic;
 
class app {
  static void Main() {
    string[] names = { "Burke", "Connor", "Frank", 
                       "Everett", "Albert", "George", 
                       "Harris", "David" };
 
    IEnumerable<string> query = from s in names 
                               where s.Length == 5
                               orderby s
                               select s.ToUpper();
 
    foreach (string item in query)
      Console.WriteLine(item);
  }
}

You can see where we query the data, you just simply do something like “from s in names where s.Length == 5 orderby s select s.ToUpper();”  This clearly is close enough to SQL that anyone with experience with SQL programming will understand it and get used to doing this, but this means that if there is a typo, or any other problem in the query, you will find it at compile time.

Linq to SQL

For SQL, there are some specific things built into Linq.  You can read all about it here.  The main thing to know is that there is a DataContext object which does most of the interaction for you.  If you are in Visual Studio and create a Linq to SQL object in there,  you can point it to any/all of your tables and then access them in a very Object Oriented manner.  And when you are done changing/inserting things into the database, simply call DataContextInstance.SubmitChanges() and it will take care of updating things.

This is a very powerful and intuitive language and I am just starting to wrap my head around it.  Hope that this makes you want to try it out also and see what you think.

Posted 20 October 08 06:00 by Tom | 0 Comments   
Filed under , ,
New place to find some great web information from Microsoft

There is a new site that has a lot of really cool information from Microsoft in the web space.  Take a look at http://www.microsoft.com/web/default.aspx

This was talked about by Joe here.

There you can get to things like blogs and other great content related to web development.  You can also download the new Microsoft Web Platform Installer.  This package gives you everything you need to get started with our web development environment. It includes the pieces that allow you to develop your web pages as well as the pieces needed to run your pages.  And, it supports both x86 and 64-bit architectures!

I also really enjoy looking at the editor’s picks on the site.  They have some great information and it is easy to use and intuitive.  Like the article linked there: Microsoft: Developers will get Windows 7 alpha next month.

Posted 17 October 08 10:34 by Tom | 0 Comments   
Filed under , ,
Who are you most looking forward to listening to at the PDC

There are a lot of great speakers and a lot of great topics this year at the PDC.  Who are you looking forward to hearing from the most?

Of course there are some great keynote speakers like Scott Gutherie but for the sessions, here are my favorites:

  • ASP.NET 4.0 Roadmap by Scott Hunter
  • ASP.NET and JQuery by Stephen Walther
  • ASP.NET MVC: A New Framework for Building Web Applications by Phil Haack
  • Deep Dive: Building an Optimized, Graphics-Intensive Application in Microsoft Silverlight by Seema Ramchandani
  • Live Services: Mesh-Enabled Web Applications Using the Live Framework by Arash Ghanaie-Sichanie
Posted 16 October 08 06:00 by Tom | 2 Comments   
Filed under , ,
Videos are coming – suggested topics?

So I have started to create some videos showing various things that you can do.  Are there specific things that everyone would like to see?  I’d like to build a list of the things you want and then I can start knocking them out.  I’m figuring most of them are going to be around debugging and probably around ASP.NET but feel free to suggest other things as well.

For example:

  • How to get sos to work when debugging on another machine.
  • What is a good way to know if a memory problem is managed or native?
  • How do I print out the column names of a DataTable?
  • How can I find out what is stored in the ASP.NET Cache?

These are simply examples.  Please let me know what you would like and be as specific as possible.

Also, keep in mind that we have a bunch of development videos already up on http://www.asp.net/learn.

Posted 13 October 08 06:00 by Tom | 2 Comments   
Filed under , , , ,
XPerf: A CPU Sampler

Seema just had a great about using XPerf to troubleshoot CPU issues when using Silverlight.  This can also be used in the same way to troubleshoot ASP.NET or IIS.

What can XPerf tell you?  Seema answers that question, it can find out:

  • Is my app asking Silverlight to constantly spin on CPU cycles.

  • Whether one UI layout or design is more expensive than the other.

  • Whether the time is spent in drawing (agcore.dll), the plug-in’s interactions with (npctrl.dll), or in compilation/JIT (coreclr.dll)

  • How much is stretching/blending/rotating that video going to cost in terms of CPU cycles? How about if you encode it differently?

You can read more about XPerf and how to download and use it from Seema post here.

Note: The tools only work on Vista and Windows Server 2008.

Getting SOS to work, a historical view

When you try to debug a managed application using Windbg and SOS, there have been issues over the years that have come up with trying to get the extension to work properly.

The major stumbling block has been to get it to load the proper files for it to work.  These files have changed over the years.  For example:

  • For .NET 1.0, we required a BIN file
  • For .NET 1.1, the BIN information was pulled automatically
  • For .NET 2.0, we require a mscordacwks file

So why do we have these files?

 

These files are the method that the extension uses to know where specific information is inside of the process.  The easiest way to get this information is with symbol files.  The issue is that external to Microsoft that information is not available and so the extension would not be able to give you the information properly.  So the solution was to create a file which references where all of the important information is stored.  These offsets are then stored in this file and the extension can load that file and see where to pull the data from.

For .NET 1.0, you can still get the BIN files by searching for SOS on the download site like this.

For .NET 1.1, we moved this file to into the mscorwks.dll and mscorsvr.dll files.

For .NET 2.0, we moved this information into the mscordacwks file.  This file needs to match up with the given version of the framework.  It is also best to make sure the SOS.dll matches up with the version as well.  So if you want to debug .NET 2.0 SP2, use the SOS.dll that shipped with .NET 2.0 SP2.

One other side, note, you must use the same architecture of debugger as the process was.  So if you want to debug ia64, you must use an ia64 debugger.

Posted 09 October 08 06:00 by Tom | 3 Comments   
Filed under , ,
More Posts Next page »

Search

Go

This Blog

Syndication

Page view tracker