Tuesday

how to configure VB6 works with TFS:

Read
download


more...

copy odbc from one computer to another


1.if this i user odbc run regedit.exe and export this folder into .reg file.
HKEY_CURRENT_USER\Software\ODBC
2.copy .reg file on target machine and double click on .reg file to add all keys to registry.

If they are System DSN odbc you have to do the same operations for
HKEY_LOCAL_MACHINE\SOFTWARE\ODBC
registry folder.

more...

Wednesday

Derive Collection class:Override Add,Insert,Remove methods

These methods are not overridable,
will be more correctly to override InsertItem,RemoveItem methods, they will be called from other methods Add,Insert,Remove , etc

using System.Collections.ObjectModel;
using System.Diagnostics;
using System;
namespace CollectionTest
{
class Program
{
static void Main(string[] args)
{
Debug.Write("MAIN");
LimitedCollection<String> col = new LimitedCollection<String>();
col.Add("hello");
col.Insert(0,"hello");

}
}
public class LimitedCollection<T> : Collection<T>
{
protected override void InsertItem(int index, T item)
{
base.InsertItem(index, item);
Debug.Write("InsertItem called");
}
}
}

more...

Tuesday

How to create Setup project for Windows Service

How to create a Setup project for a Windows Service in Visual Basic .NET or in Visual Basic 2005
Create a Setup project for a Windows Service
This section describes how to create a Windows Service project and how to use a compiled Setup project to install the Windows Service.
Create a Windows Service project

1. Click Start, point to Programs, point to Microsoft Visual Studio .NET or Microsoft Visual Studio 2005, and then click Microsoft Visual Studio .NET or Microsoft Visual Studio 2005.
2. On the File menu, point to New, and then click Project.
3. In the New Project dialog box, follow these steps:
1. Under Project Types, click Visual Basic Projects or click Windows under Visual Basic.
2. Under Templates, click Windows Service.
3. In the Name box, type LogWriterService.
4. In the Location box, type C:\, and then click OK.
4. In Solution Explorer, right-click Service1.vb, and then click View Code.
5. In the OnStart event handler, replace the comments with the following code.

EventLog.WriteEntry("My simple service started.")

6. In Solution Explorer, double-click Service1.vb.
7. In the Properties dialog box, click Add Installer.
8. In the Properties dialog box for ServiceInstaller1, change the ServiceName property to LogWriterService.
9. In Design view, click ServiceProcessInstaller1 in the Code Editor.
10. In the Properties dialog box, change the Account property to LocalSystem. The LocalService value and the NetworkService value are only available in Microsoft Windows XP and later operating systems.

Use a compiled Setup project to install the Windows Service
After you complete the steps in the "Create a Windows Service project" section to configure the Windows Service project, you can add a deployment project that packages the service application so that the service application can be installed. To do this, follow these steps:

1. Add a new project to your LogWriterService project.
1. In Solution Explorer, right-click Solution 'LogWriterService', point to Add, and then click New Project.
2. Under Project Types, click Setup and Deployment Projects or Setup and Deployment.
3. Under Templates, click Setup Project.
4. In the Name box, type ServiceSetup.
5. In the Location box, type C:\, and then click OK.
2. Tell the deployment project what the deployment project will package.
1. In Solution Explorer, right-click ServiceSetup, point to Add, and then click Project Output.
2. In the Add Project Output Group dialog box, click LogWriterService in the Project box.
3. Click Primary Output, and then click OK.
3. For correct installation, you have to add only primary output. To add the custom actions, follow these steps:
1. In Solution Explorer, right-click ServiceSetup, point to View, and then click Custom Actions.
2. Right-click Custom Actions, and then click Add Custom Action.
3. Click Application Folder, and then click OK.
4. Click Primary output from LogWriterService (Active), and then click OK. Notice that Primary output appears under Install, Commit, Rollback and Uninstall.
4. By default, Setup projects are not included in the build configuration. To build the solution, follow these steps:
1. Use one of the following methods:
* Right-click LogWriterService, and then click Build. Then, right-click ServiceSetup, and then click Build.
* To build the whole solution at the same time, click Configuration Manager on the Build menu, and then click to select the Build check box for ServiceSetup.
2. Press CTRL+SHIFT+B to build the whole solution. When the solution is built, you have a complete Setup package for the service.
5. To install the service, right-click ServiceSetup, and then click Install.
6. In the ServiceSetup dialog box, click Next three times. Notice that a progress bar appears while the Setup program is installing the service.
7. When the service is installed, click Close.


Thursday

tinyget call samples

Invoking the page for 4000 times.

tinyget -srv:localhost -uri:/BuggyBits/Links.aspx -loop:4000

Invoking the page on 30 threads, 50 times each.

tinyget -srv:localhost -uri:/BuggyBits/FeaturedProducts.aspx -threads:30 -loop:50

Wednesday

To try find out asp.net performance leak/locks or why my .net app is slow on multiple requests :) ?


1.take memory dump and load it in windbg with "sos" as described here.
Then you can load sos commands .cmdtree c:\debuggers\cmdtree.txt
3.Evaluate clr stacks for all threads by ~* e !clrstack
or by selecting Stacs/All managed Stacks from Sos Commands menu window.
as result you will see call stack lists,similar stacks like for memory dump.
4.Look for System.Threading.Monitor.Enter or System.Threading.Monitor.Exit in page load stacks , that might indicate that static object is using
that might cause slow performance for multiple requests.

5.to monitor sysncBlock use !syncblk commad
it will show who owns the lock and how many people waiting for it in "MonitorHeld" column.

"Info" column will - contains thread number [thr] that locking, use this commands:
~[thr]s
!clrstack
to display locking stack and which give you a chance to locate which procedure holding it.

also debugging and preview of dump files will be available in Visual studio 2010.

more...

How to find memory leak in .net application:


1.Create dump file of application process in windows , you can use this tool

DebugDiag (free tool from Microsoft)
Open it, go to "process" tab and select "create dump file"
2. Download and install
windbg
Start windbg and drag dump file there.
3.if it's dot.net you have to load sos extension , in windbg command line , type:
.loadby sos mscorwks
4.then !dumpheap -stat you will get list of all .Net objects in memory/dump
if you want to get specific instances , you can hit:
!dumpheap -mt [addr] - where [addr] is addr from left column in windbg
you will receive list of objects loaded into memory , by dump out do objects:
!do [addr] you will dump specific objects with it's properties.
when you do !do [addr] when [addr] of specific property you will get particular value of that property.
5.if you dumped web-application and see aspx pages this is not good.
you can get static objects by this command (it will show links on cache objects as well):
!gcroot [addr] where [addr] -- address of page in memory

As alternative you can use different analysis from [Analysis] tab in DebugDiag.
Memory Analysis gives a nice report.

Friday

micosoft sql server SHRINKFILE command:

first find file_name by:
select * from sys.database_files
then:
DBCC SHRINKFILE (mydb_log, 1000) WITH NO_INFOMSGS

imagemagic add text to image

rem different types of text annotations on existing images rem cyan yellow orange gold rem -gravity SouthWest rem draw text and anno...