Galin Iliev's blog

Software Architecture & Development

.NET 2.0 SP1 improves performance in ADO.NET

ADO.NET team made a blog post in which describes the how much the performance is improved by SP1.

For a complex real world web application, like Petshop, the improvement is not so big, since the application does many other things in addition to data access, but still you should get part of the benefits.

A summary of our lab numbers, just as a reference of how much improvement you can get:

Scenario .NET FW 2.0 .NET FW 2.0 SP1 Improvement
SqlReader 14855 18100 27.3%
DataSet insert 9637 12890 40.8%
Pet Shop 4.0(Browse the store) 22.44 24.40 8.72%
Pet Shop 4.0 (Buy some pets) 21.54 23.04 6.99%

* Average throughput, over a set of runs, on 4 proc dual core servers with W2K3 SP1, 16 Gb. of RAM, with a sample average load (not by far peak capacity). Hardware differences, network conditions and the way your scenario is written affect performance, among many other things, so your mileage may vary.

If you haven't installed it yet - go for it. You can only benefit from it!

Internal .NET Framework Data Provider error 6.

For all these year I've been using .NET framework this is first encrypted exception that I get. Here is what I get from quick search

If you are getting the error “Internal .Net Framework Data Provider error 6″ and you are using SQL Server 2005 with database mirroring know that its a bug in the SQL managed client code.

Check out KB article 944099 for more info.

At the time of writing this post the only solution for this problem is a private hot fix that you need to obtain from Microsoft.

The links around the web for the Hotfix Request Web Submission form seems to be broken. I’ve contacted Microsoft and got this replacement link.

Use this link to contact Microsoft, state that you require the hotfix for KB article 944099 and submit the form. You will be contacted shortly by a Microsoft representative that will give you the download details or request further information to better understand your needs.



Call MethodInfo.Invoke with an out parameter

Here is a trick inspired by Visual C# Forums and C# MVP Mattias Sjögren. In this code snippet int.TryParse() method is called using reflection and get result from out parameter.

int parNum = 0;
string parText = "99";
object[] methodParms = new object[] { parText, parNum };

MethodInfo methInfo = parNum.GetType().GetMethod("TryParse", new Type[] { typeof(string), typeof(int).MakeByRefType() });
methInfo.Invoke(null, methodParms);
parNum = (int)methodParms[1];
Console.WriteLine("Parsed number:{0}", parNum);

Text/Value pair in ASP.NET AJAX Autocomplete Extender

The scenario

I guess you are familiar with the case when user have a screen in which ClientId is needed in text box but it is quite unusual to let the users and clients to remember all those numbers. To facilitate users and clients you put DropDownList control (in case you are developing ASP.NET app) filled with ListItem elements and every item has it's Text and Value properties. Sounds common, isn't it?

The challenge

In today's world of Web 2.0  and DHTML mashups you may have same scenario like one above but needed to be implemented in similar behavior like ASP.NET AJAX Autocomplete extender does.

In other words - you have a textbox and a list with items but when user select an item instead if item's text some number or ID is put in the extended textbox.

The Solution

ASP.NET AJAX Autocomplete extendeer can be adjusted to behave that way.

First we should provide Text and Value pair... How to do that as there is strict definition of expected XML Web Service method?

ServiceMethod - The web service method to be called. The signature of this method must match the following:

public string[] GetCompletionList(string prefixText, int count) 

Note that you can replace "GetCompletionList" with a name of your choice, but the return type and parameter name and type must exactly match, including case.

There is still way. We just need to pass pair in serialized way. If you take a look at Autocomplete test page source you will see that method

   1: [System.Web.Services.WebMethod]
   2: [System.Web.Script.Services.ScriptMethod]
   3: public static string[] GetCompletionListWithContextAndValues(string prefixText, int count, string contextKey)
   4: {
   5:     System.Collections.Generic.List<string> items = new System.Collections.Generic.List<string>(GetCompletionListWithContext(prefixText, count, contextKey));
   6:        for (int i = 0; i < items.Count; i++){
   7:           items[i] = AjaxControlToolkit.AutoCompleteExtender.CreateAutoCompleteItem(items[i], i.ToString());
   8:        }
   9:            return items.ToArray();
  10: }

So if we use helper method below we can get serialized pair

AjaxControlToolkit.AutoCompleteExtender.CreateAutoCompleteItem(text, val);

But that's not all. Unfortunately we have to modify the AutoCompleteBehavior.js in order to get value instead text property. More precisely we have to add one more line in it... in function _setText - it should start like this:

_setText: function(item) {
/// <summary>
/// Method to set the selected autocomplete option on the textbox
/// </summary>
/// <param name="item" type="Sys.UI.DomElement" DomElement="true" mayBeNull="true">
/// Item to select
/// </param>
/// <returns />

var text = (item && item.firstChild) ? item.firstChild.nodeValue : null;
text = (item && item._value) ? item._value : text;

Note: The very last line is added by us. This is enough to test. Rebuild the AjaxControlToolkit source, use produced assembly instead of downloaded one and enjoy.

Hope this helps!

.NET 2.0 and 3.0 SP1

Service Pack 1 for .NET Framework 2.0 and 3.0 are released.

Microsoft .NET Framework 2.0 Service Pack 1 provides cumulative roll-up updates for customer reported issues found after the release of Microsoft .NET Framework 2.0. In addition, this release provides security improvements, and prerequisite feature support for .NET Framework 3.0 Service Pack 1, and .NET Framework 3.5.

Here is full list of fixes in .NET 2.0 SP1.

Download locations:

.NET Framework source code is LIVE for stepping into it

.NET source code was promised to be open a while ago and now this is fact. Shawn Burke posted on his blog steps to enable it.

Here are basic ones:

  1. Install the Visual Studio 2008 QFE. (If you get an error installing the Hotfix , try inserting your VS 2008 DVD and then running the Hotfix EXE again. the work in this is in progress)
  2. Start Visual Studio 2008 and bring up Tools > Options > Debugging > General.  If you are running under the Visual Basic Profile, you will need to check the box on the lower left of the Options Dialog marked "Show All Settings" before continuing (other profiles won't have this option).

    Set the following two settings:

    • Turn OFF the "Enable Just My Code" setting
    • Turn ON the "Enable Source Server Support" setting

  3. Next, bring up the "Symbols" Page and set the symbols download URL and a cache location.  Specifically, set the three settings below:

    • Set the symbol file location to be:
    • Set a cache location.  Make sure this is a location that your account has read/write access to.  A good option for this is to place this path somewhere under your user hive (e.g. d:\cache\vs2008\symbols)
    • Enable the "Search the above locations only when symbols are loaded manually" option.


(via Shawn's blog)

And this is it....Enjoy!

Read the full blog post at Shawn's blog

Top 10 Hidden Gems in SQL Server 2005

Here are ten precious SQL Server 2005 features that could help you make your DB flying:

  1. TableDiff.exe
  2. Triggers for Logon Events (New in Service Pack 2)
  3. Boosting performance with persisted-computed-columns (pcc).
  4. DEFAULT_SCHEMA setting in sys.database_principles
  5. Forced Parameterization
  6. Vardecimal Storage Format
  7. Indexing made easier with SQL Server 2005
  8. Figuring out the most popular queries in seconds
  9. Scalable Shared Databases
  10. Soft-NUMA

Read full article on MS TechNet

TechEd Video - Framework Engineering: Architecting, Designing, and Developing Reusable Libraries

As we know it is very important to write reusable code as this lower the cost of the product and decrease development time. Here is recorded nice presentation of Krzysztof Cwalina on TechEd "Framework Engineering: Architecting, Designing, and Developing Reusable Libraries".

Krzysztof is kind enough to publish slides in XPS format (1.25 MB).

Download video in WMV format (01:07:23 and 371 MB)

image image

Framework Engineering: Architecting, Designing, and Developing Reusable Libraries

This session covers the main aspects of reusable library design: API design, architecture, and general framework engineering processes. Well-designed APIs are critical to the success of reusable libraries, but there are other aspects of framework development that are equally important, yet not widely covered in literature. Organizations creating reusable libraries often struggle with the process of managing dependencies, compatibility, and other design processes so critical to the success of modern frameworks. Come to this session and learn about how Microsoft creates its frameworks. The session is based on experiences from the development of the .NET Framework and Silverlight, and will cover processes Microsoft uses in the development of managed frameworks