Sunday, December 24, 2006

Maximum URL length in HTTP request.

Previously, there were limitations on the maximum length of URL - 256 characters.
But now, in HTTP 1.1 length of URL is 2,083 characters.
Limiting only to GET. For POST a length is not limited.

Monday, December 11, 2006

Custom object and ToString()

It is known that in the C # any object can be shown in the form of string by the method ToString () but what to do if you need to make such an operation with custom object?
That is one solution :

public int Id
get { return id; }
set { id = value; }
private string name;
public string Name
get { return name; }
set { name = value; }
private DateTime birthday ;
public DateTime Birthday
get { return birthday ; }
set { birthday = value; }

public Customer()
{ = 5; = "John Smith";
this.birthday = new DateTime(1945, 10, 12);


To continue press "read more"....

public override string ToString()
StringBuilder builder = new StringBuilder();

Type type = this.GetType();
PropertyInfo[] propertiesInfo =
foreach (PropertyInfo property in propertiesInfo)
builder.AppendFormat("{0} = {1} \n",
property.GetValue(this, null));

return builder.ToString();


kick it on

Thursday, November 30, 2006

Writing log message to file via Message Queue

using System;
using System.Configuration;
using System.Messaging;
using System.IO;

namespace Test
public class QSend
private System.Messaging.MessageQueue mq;
private string exQ;

public QSend()
mq = new System.Messaging.MessageQueue(
LogItems inLogItems = new LogItems();
inLogItems.FileName = @"d:\mgslog\Log.txt";
inLogItems.Message = " my message";
catch(MessageQueueException ex)
exQ = ex.Message;

public class QRecieve
private System.Messaging.MessageQueue mq;
private string exQ;

public QRecieve()
mq = new System.Messaging.MessageQueue (@".\Private$\MyQ");
mq.Formatter =
new System.Messaging.XmlMessageFormatter (
new Type[] {typeof (LogItems)}) ;
System.Messaging.Message msg = mq.Receive();
LogItems outLogItems = (LogItems) msg.Body;
using( StreamWriter sw =
new StreamWriter(outLogItems.FileName,true))
+ outLogItems.Message);
catch(MessageQueueException e)
exQ = e.Message;


public class LogItems
private string _fileName;
private string _message;
public string FileName
get {return _fileName;}
set {_fileName = value;}
public string Message
get {return _message;}
set {_message = value;}

kick it on

Debugging and Tracing Your Website C# (Video)

Tuesday, November 21, 2006

Convert any possible type to T in .Net 2005

private T TryConvert <T>(object o, T defaultValue, bool isThrowException)
    T convertedValue = defaultValue;
     if (o != null)
       convertedValue = (T)Convert.ChangeType(o, typeof(T));
     if (isThrowException)
   return convertedValue;

How to use:

Let us suppose you have HttpRequest with some parameters:
ID , Name and Flag
Example 1. Simple using
private void Examle()
int id =
TryConvert<int>(Request["id"], -1,
string name =
TryConvert<string>(Request["name"], string.Empty,
bool flag =
TryConvert<bool>(Request["Flag"], default(bool),

Example 2. Using in enum

 public enum Week

private void Examle2(Week w)
Week day = TryConvert<Week>(w, Week.Sunday, true);

Thursday, October 26, 2006


NMock is a dynamic mock object library for .NET. Mock objects make it easier to test single components—often single classes—without relying on real implementations of all of the other components. This means we can test just one class, rather than a whole tree of objects, and can pinpoint bugs much more clearly.
Home page

Comparison of logging services.

We have lead comparison 3 popular services:
Microsoft Enterprise Library

The scenario of the test:
1. Reading of a line from a DB.
2. Record of a line in a DB.

Here results on 500 inquiries:

Log4NetEnerprise LibrarySyslog
Concurrency Level252525
Time taken for tests1.617758 seconds1.794552 seconds1.270281 seconds
Complete requests500500500
Failed requests000
Write errors000
Total transferred566968 bytes701000 bytes695000 bytes
Requests per second309.07 [#/sec] (mean)278.62 [#/sec] (mean)393.61 [#/sec] (mean)
Time per request80.888 [ms] (mean)89.728 [ms] (mean)63.514 [ms] (mean)
Time per request(mean, across all
concurrent requests)
3.236 [ms] 3.589 [ms] 2.541 [ms]
Transfer rate341.83 Kbytes/sec] 381.15 [Kbytes/sec]533.74 [Kbytes/sec]

Wednesday, September 20, 2006

HttpHandler in WebSite VS 2005

This example intended to case, when classes located in App_Code.


public class TestHandler : IHttpHandler
public TestHandler() {}

public void ToDo()

public bool IsReusable
get { return true; }
void IHttpHandler.ProcessRequest(
               HttpContext context)      

<add path="test.test" verb="*"
 type="TestHandler, App_Code" />

Thursday, July 27, 2006

Add an uninstall and him shortcut to .NET deployment project in VS2005

1. Create simple project UninstallApp.
2. Add in Main()

string[] arguments = Environment.GetCommandLineArgs();

foreach(string argument in arguments)
string[] parameters = argument.Split('=');
if (parameters[0].ToLower() == "/u")
string productCode = parameters[1];
string path = Environment.GetFolderPath(Environment.SpecialFolder.System);
Process proc = new Process();
proc.StartInfo.FileName = string.Concat(path,"\\msiexec.exe");
proc.StartInfo.Arguments = string.Concat(" /i ", productCode);


3. Create new setup project
4. Add UninstallApp.exe to "Application Folder" in 'File System' part
5. In "User's Program menu" create shortcut to UninstallApp.exe and in properties of this shortcut in parameter 'arguments' insert value "/u=[ProductCode]".
6.Rebuild deployment project.

Good luck ;)

Friday, June 16, 2006 This is very good site for Web Programmers. If you use in CSS,PHP,MySQL,ASP / VBScript,mod_rewrite,JavaScript,HTML Character Entities,RGB Hex Colours you must to add this site to your favorites. Also very recomended to web developers in any platform.

Sunday, June 04, 2006

Intellisense for SQL Query Analyzer

SQL Prompt™ is freeware tool which is а intellisense for SQL Query Analyzer.



Here extremely simple service for creation of buttons "On the fly"...

Clean AJAX

*AJAX - Asynchronous JavaScript and XML.
Clean AJAX - is an open source engine for AJAX which, is technology of creation asynchronous HTTP requests. Clean AJAX is open source and released under a GNU General Public License, download is available from souceforge.

For more information : Click here

Wednesday, May 17, 2006

Event Log Explorer

The small freeware utility for monitoring and the subsequent analysis of the events which have been written down in system log of operational systems of family Windows NT (NT/2000/XP/2003). It is called to expand functionality of built in component Event Viewer from OS and to add new opportunities its Interface it is extremely simple, divided for convenience into two windows. In left the tree of magazines (by default in Windows XP them three is displayed: for appendices, safety and system), and in right - tables with brief data on events, somehow: date, time, a code of event, a source and other. The arrangement of windows in the right half is limited by nothing, it is possible to look through simultaneously set of logs without restrictions. Probably to organize the selected lists for the separate computers connected through removed access on a network. Functions archiving old logs are supported, there is an advanced system of a filtration by various criteria and text search, and also the expanded functions of a press and export to various formats (HTML, TXT or in Excel). The program is very useful, as by means of it it will be much easier (unlike a standard browser of events Windows) to trace failure of this or that appendix, systems or the driver.
Download(1.0 MB)

Wednesday, May 10, 2006

HTMLCrypt 2.60

HTMLCrypt is a software to protect your web pages and prevent others from viewing and reusing your web page source code, including HTML source code, JavaScript, VBScript, text, links and graphics, thus protect your hard work and unique design on the web. In addition to encrypt the source code and make it impossible for people to read, HTMLCrypt also takes some additional measures to further protect your web page, such as disable right mouse click, disable link display in status bar, disable text selection, disable off-line use, disable page printing, etc. The protected page by HTMLCrypt will have the same appearance as the original one.

Thursday, May 04, 2006

SqlDependency in VS.NET 2005

SqlCommand command = new SqlCommand("Select * from Table");
// Clear any existing notifications
 command.Notification = null;
// Create the dependency for this command
 SqlDependency dependency = new SqlDependency(commmand);
// Add the event handler
dependency.OnChange += new OnChangeEventHandler(OnChange);

voidOnChange(object sender, SqlNotificationEventArgs e)
    SqlDependency dependency = sender as SqlDependency;
    dependency.OnChange += OnChange;
    //Handler for Object

Monday, May 01, 2006

Storing Code Snippets in VS.NET

Add a code snippet to a tab of the Toolbox as follows:

  • 1.Select the code snippet in the code file
  • 2.Copy the text.
  • 3.Click the desired tab on the Toolbox.
  • 4.Right-click the area below the tab.
  • 5.Select "Paste" from the context menu.

Sunday, April 30, 2006

Split in SQL

Split list of numbers ('1, 2, 3, 4, 67, 87') to table.

Input: : List of numbers (0;1;5;45;...)


0 1545...

A using: SELECT * FROM Split('0;1;5;45;',';')


@list varchar(8000), -- List of integer with any delemiter

@delimiter CHAR(1) -- Delimetr

@list_int TABLE (item int) --list of integer

  DECLARE @position int, @itemvarchar(20)

   WHILE @list <> ''
     SET @position = CHARINDEX(@delimiter, @list)
     IF @position = 0
     SET @position = LEN(@list) + 1

     SET @item=LEFT(@list, @position - 1)
     INSERT INTO @list_int VALUES(CAST(@itemAS int))
     SET @list = STUFF(@list, 1, @position, '')

Use of conditional attributes in .NET

Attribute Conditional serves for creation of conditional methods, i.e. methods which are carried out only when the parameter of attribute is the symbolical constant certain by the instruction *define or is registered in properties the project.
Simple example. A conclusion of the message about trial version and about the registered version depending on attribute.

Open new Console Project.

Add a reference
using System.Diagnostics;

Add 2 methods to class:
[Conditional ("TRIAL")]
public static void Remind()
  Console.WriteLine("Please register your version!" );

[Conditional ("FINAL")]

public static void Hello()

  Console.WriteLine("Thanks for registration!");

Add to project properties -> Build -> Conditional compilation constants :

Compile and Run.

Tuesday, April 25, 2006

Google advanced operators



Uses operators

What Google site writes about blog? inanchor:blog

site: inanchor:

Find car BMW in UK

Results from all word: BMW

Result from UK and other link:


Results from UK only: intitle:BMW


Find info about bugs

Any bugs: Bugs

Any bugs except of computer bugs: Bugs -computer


Understand the DOT.NET dataset class structure


Google images

What Blog is?

Define: blog


Find info about mobile/cellular phones

Intitle: phones intitle:~mobile


Find PowerPoint presentation about cars/auto

~car filetype:ppt

Synonyms(~), filetype

Find any installation guide in flash

"installation guide" filetype:swf

Exact match(""), filetype

Find middle Vladimir Putin name

"Vladimir * Putin"


Effect of incomming links

Click here (Adobe, XE, Macromedia)

List of operators:


Inurl, allinurl



















Sunday, April 23, 2006

Exact measurement of performance in Dot.Net

Utils.PerfMeter - unpretentious class for exact gauging performance in Dot.Net.
Measures much more precisely than Environment.TickCount. Environment.TickCount has accuracy 10 milisecond,
that for measurement of short sites does not approach.
Use QueryPerformanceCounter allows to provide very high accuracy.
To use so:
//Define variable
PerfMeter timer = new PerfMeter();


// A code for test.......

//Print result to console
Console.WriteLine("Execution time in seconds: {0:### ### ##0.0000}"

//You can to use one variable several times

Class code:
using System;
using System.Runtime.InteropServices;

namespace Utils

/*This structure allows to count up speed of performance of a code one of the most exact of ways. Actually calculations are made in steps of the processor, and then translated in miliseconds (the decimal part is shares of second).

  public struct PerfMeter
  Int64 _start;

  /// Start timer
  public void Start()
  _start = 0;
  QueryPerformanceCounter(ref _start);
  /// Finished calculation time executions and returns time in seconds.

  /*Return: Time in seconds spent for performance of a site of a code. The   decimal part reflects shares of second */
  public float End()
  Int64 end = 0;
  QueryPerformanceCounter(ref end);

  Int64 frequency = 0;
  QueryPerformanceFrequency(ref Frequency);
  return (((float)(end - _start) /(float)freq));

  static extern bool QueryPerformanceCounter(ref Int64 performanceCount);

  static extern bool QueryPerformanceFrequency(ref Int64 frequency);

BIOS error signals

During inclusion of a computer the sound signal is always audible, but sometimes it is more, than a lonely signal. You what is it? Ask, and the answer will be not pleasant - there was a problem with hardware. This signal publishes BIOS, and values of signals are resulted in tables below:




- *

Power Supply is out of order

2 short

Clock memory error

3 short

Error in first 64kb of memory

4 short

System timer error

5 short

CPU is out of order

6 short

Keyboard controller is out of order

7 short

Motherboard is out of order

8 short

VGA card is out of order

9 short

Test BIOS error

10 short

Can not write to CMOS

11 short

Motherboard cache memory is out of order

1 long + 2 short

VGA card is out of order

1 long + 3 short


1 long + 8 short

The monitor is not connected.




2 short

little errors**

3 short

Keyboard conroller error

1 long +1 short

Memory error

1 long + 2 short

VGA card is out of order

1 long + 3 short

Keyboard initialization  error

1 long + 9 short

Read error from ROM

short, recurrent

Power Suplly is out of order

long, recurrent

Memory problem


Power Suplly is out of order

* - a absence of any signal.

** - Problem in CMOS Setup or motherboard.

Hello, Word

Today I open the blog. I shall publish to become connected with development & computers. Examples of code, tools and other items. Problems of OS, illumination and comparison of new hardware, and also tips and tricks devoted to a computer.