Galin Iliev's blog

Software Architecture & Development

How to create software/libraries that will be used?!

We, the devs, like to create software - there is no doubt in this. We put our hearts, our souls in it. That's why we are much more productive when we work on something we really like. And when our creature has success - it is wide used by users - we feel great - this is a great reward for long hours spent in front of the screen :) . But can we know if the piece of the code will be wide used?!

The answer is YES. By simply following this mind flow:

So, does this work? It does, but it is cumbersome to write. And if it is too cumbersome, I already know that I'm not going to use it. I might start doing it, but I would soon give up. Are there ways to ease the pain?
Luca Bolognese (Lead Program Manager for the Visual C# team)

Yes, I know some things cannot be simple :) But this doesn't mean we cannot try to make them simpler.


I remember a short ads... in Discovery channel  "Guess the gadget" in which some very complicated inventions from end of 19th century were shown as they are supposed to ease the life. But they were so complicated so you cannot even guess what they do. (How can you used it as you don't know their main use and just for it you need training :) )


So stay with KISS principle or your products won't be used at the end of the day...


And as Albert Einstein said "everything should be made as simple as possible, but no simpler" [wikipedia].

Building a Volta Control : A Flickr Widget

Tanzim Saqib wrote a nice article about Microsoft Volta in which he gives step by step instructions on how to write a Flickr control that you can reuse  in your pages.

Microsoft Live Labs Volta is Microsoft's emerging toolset that enables developers to build multi-tier web applications by applying familiar .NET techniques and patterns. The intended use of this toolset is for Developers to build web application as .NET client application, and then specify the portions of the codes that will run on the client and server side. The compiler then creates cross browser JavaScript, Web Services, communication, serialization, security etc. to tie the tiers together. This article is based on the first CTP of Volta considering its current limitations. We will see how we can create a Volta control that the compiler can convert into an AJAX Widget without requiring us writing a single line of JavaScript code. We will write code in our very familiar C# language.

Interesting reading! Full Article.

.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