Sunday, October 28, 2007

Care about Event Memory Leaks with Delegate.GetInvocationList()

Subscribed events are one of the most common reasons of memory leaks in .Net. This means that if you have an object that has an event

and there are other object that are subscribed to that event, the original object won't be properly disposed until all events are unsubscribed since

an event is a strong reference.

 ....

public partial class MyForm : Form
{
public event EventHandler OnDoMyFormThing;

public MyForm()
{
InitializeComponent();
}

private void button1_OnClick
{
MessageBox.Show(
"Test of OnDoMyFormThing event"
);
OnDoMyFormThing(this, new EventArgs());
}

protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
foreach (EventHandler eventDelegate
in
OnDoMyFormThing.GetInvocationList())
OnDoMyFormThing -= eventDelegate;
components.Dispose();
}
base.Dispose(disposing);
}
}



 


To full  article click here

Tuesday, October 23, 2007

Convert UTF-8 to Unicode

private static string Utf8ToUnicode(string utf8)
{
    return Encoding.Unicode.GetString(
        Encoding.Convert(
        Encoding.UTF8,
        Encoding.Unicode,
        Encoding.UTF8.GetBytes(utf8)));
 }

LINQ solution:
private static string Utf8ToUnicode(string utf8)
{
  return   Encoding.UTF8.
       GetString(input.Select(item => (byte)item).ToArray()); 
}

Strategy Pattern in C# 2.0

Strategy pattern can very handy when a system designer or architect wants to separate algorithms from the system implementation. Also with strategy pattern approach it is very easy to select between different algorithms on the fly. With the introduction of generics in .NET 2.0 implementing strategy pattern is even more easy.

Click Here

 

 

via DotNetKicks.com

Sunday, October 21, 2007

Full guide to create Installer class in VS.Net 2005

6 pages of amazing guide by devCity.net explains all point of deployment project and include follow parts:

  • Requirements 
  • Terminology
  • How to create an Installer Class
  • Un-written rules
  • Unpleasent features
  • Using these events (about Installer Class events)
  • Using the Commit event to change the target directory permissions.
  • Using the Uninstall event to clean the target directory
  • Where is the "NT AUTHORITY\SERVICE" account coming from?
  • Exceptions and Exception handling in your installer class.
  • Adding user interfaces (forms) to your installer class.
  • Launching your application after installation.
  • Conclusions.
  • References.

To read "Visual Studio 2005 Setup and Deployment Installer Classes and Custom Actions" CLICK HERE

kick it on DotNetKicks.com

Listas - new feature from Microsoft

At Live Labs, we are always experimenting with new ideas that we think will be useful.  Today we are releasing our latest technology preview:

Listas (http://listas.labs.live.com)

Listas is a tool for the creation, management and sharing of lists, notes, favorites, and more. It allows you to quickly and easily edit lists, share them with others for reading or wiki-style editing, and discover the public lists of other users.  We encourage you to try using it for meeting notes, bookmarks, shopping lists, to plan a night out, or whatever other creative ways you can think of....

kick it on DotNetKicks.com

Sunday, October 14, 2007

Sharp Cache Session Manager

The SharpCacheSessionManager is a HttpHandler that allows to display the entries stored in the Cache, Session and Application object. You can view the data stored inside the objects and you can also remove the objects from the corresponding storage. To download the SharpCacheSessionManager click HERE

via Christopher Steen

 kick it on DotNetKicks.com

Wednesday, October 10, 2007

Monday, October 08, 2007

Find and get list of controls on page

If you want to find list of controls on Page you can use this method:
private List<T> GetControls<T>() where T:Control
{
List<T> list = new List<T>();
foreach (Control rootControl in Controls)
{
foreach (Control control in rootControl.Controls)
{
if (control as T != null)
{
list.Add(control as T);
}
}
}
return list;
}
And a using is very simple. In example you can see how to change background to all labels:
List<Label> list = 
GetControls<Label>();
list.ForEach(
delegate (Label lab)
{
lab.BackColor =
System.Drawing.Color.Pink;
}
);

 


kick it on DotNetKicks.com

Sunday, October 07, 2007

A Visual Guide to Version Control

A beautiful, "highly visual" overview of Version Control, (a.k.a. Source Control). It also references Subversion command line examples, but the overview applies to most version control systems by BetterExplained.

To read a full article click HERE.

Sunday, September 30, 2007

What is a Fluent Interface?

Full article "How to design a Fluent Interface", compares and examples see HERE

Get last day of the month

DateTime GetLastDayOfMonth(DateTime date) 
{
return
new DateTime(date.Year,
date.Month,
DateTime.DaysInMonth(
date.Year,
date.Month));
}

Thursday, September 20, 2007

Accordion 2.0 by Kevin Miller

Kevin Miller has updated  to version 2.0 his extraordinary  AJAX  control ACCORDION


AJAX Accordion

New futures:

  • Open/Close functionality added (Click on an active accordion).
  • Nested Vertical Accordions
  • Accordions will dynamically resize on content added REAL TIME!
  • ...lots of bug fixes!

 Very simple using:

Include 3 JavaScript files to HTML page

<script type="text/javascript" 
src="javascript/prototype.js"></script>
<script type="text/javascript"
src="javascript/effects.js"></script>
<script type="text/javascript"
src="javascript/accordion.js"></script>
and...
<h2 class="accordion_toggle">Title Bar</h2>
<div class="accordion_content">...</div>
...
...
...
<h2 class="accordion_toggle">Title Bar</h2>
<div class="accordion_content">...</div>

More option see here (In toggle "How to use")


kick it on DotNetKicks.com


Sunday, September 16, 2007

Sunday, September 09, 2007

Determining when a procedure has been changed

SELECT 
[StoredProcedure name]
,Modify_date
,Create_date
,*
FROM
sys.procedures

Labels:

Wednesday, September 05, 2007

CSS Table Gallery

Candy style
CSS Candy style

Red and Black style
CSS Red and Black style

The OC style
CSS The OC style

To more styles click here

10 SQL Server Functions That You Hardly Use But Should

A using and explanation next SQL functions:

BINARY_CHECKSUM
SIGN

COLUMNPROPERTY
DATALENGTH
ASCII, UNICODE
NULLIF
PARSENAME
STUFF
REVERSE
GETUTCDATE

Labels:

Tuesday, September 04, 2007

Clear cache and buffers in MSSQL

Use this to clear the cache and buffers to ensure comparison are accurate.

dbcc freeproccache
go
dbcc dropcleanbuffers
go
Labels:
 
Labels: