Wednesday, July 21, 2010

WinDbg SOS Find Strings in .NET Application

Find all strings loaded in the .net process
!dumpheap -strings

Output for dumping all strings, the total size is the parameter for min and max
















Count Total Size String Value
1 20 "z"
1 20 "y"


Find all the string between specific sizes with and ----- between each listings

.foreach(loadedString {!dumpheap -type System.String -min 40 -max 50 -short}){!do -nofields loadedString;.echo -------------}

Make sure that the range is small as if its too large the windows debugger hangs.

Its better to use the previous command and find out the length of the string and then use the
!dumpheap -type System.String -min 40 -max 50 -short to get the address of these strings

Output for this would be
Name: System.String
MethodTable: 703588c0
EEClass: 7011a498
Size: 44(0x2c) bytes
(C:\Windows\assembly\GAC_32\mscorlib\2.0.0.0__b77a5c561934e089\mscorlib.dll)
String: eventMappings
----------------

since we have put -nofields we don't see the internal fields for String class. The "eventMappings" is the actual value present in the memory
P.S
The blanks are due to the editor not able to understand the table tag

Monday, July 19, 2010

Reading SQL Server Roll Over Trace Files into Table

The default roll over files for SQL Server 2005 Trace do not get imported by the fn_trace_gettable if this roll over is done through the trace UI. To fix this problem do the following.

Create a table to hold the trace table
SELECT * INTO Trace071910
FROM fn_trace_gettable('E:\trace_071910\Monitoring_071910.trc', default);
GO
To insert the first trace file records in to the table

Then insert the other records starting from the roll over file which starts with _1, this would start inserting all the records till the end of the trace roll over file is reached.

INSERT INTO Trace071910
SELECT *
FROM fn_trace_gettable('E:\trace_071910\Monitoring_071910_1.trc', default);
GO

In the event of the duration column not available on the trace file we can update it into the trace table with the following query

UPDATE Trace071910
SET duration = DATEDIFF (ms ,startTime ,endTime)

Here I have converted the duration to a millisecond.

Sunday, July 18, 2010

Powershell Hyper-V Commands

Check the version of Powershell in Hyper-V.

Type $Host.version

It should be version 2.0

Install the Hyper-V Module Scripts from PSHyperV_Install.zip from CodePlex

UnZip and copy the underlying HyperV_Install folder contents to the Documents/windowsPowershell/HyperV folder of the administrator, the full path should look like

c:\Users\Administrator\Documents\windowsPowershell\modules\HyperV

You could do the same to other users as well or use the installer provided to load to all users with a manual setup.

On the Hyper-V Command Prompt type Powershell to go to the powershell prompt

Type
PS>Import-Module HyperV to load the Hyper V module commands
PS>Get-VMSummary to see a list of Virtual Machines on the box
PS>Start-VM "VMElementName" to start the Machine if its not running.

Thursday, July 15, 2010

Read Only User for SQL Server

In order to create a Readonly user to have just Read out of the CRUD operations for DML Statements


1. Open Security->Logins
2. Right Click the User and choose Properties
3. Click User Mapping
4. On the Database list select the database the user is going to get associated with (Note in SQL Server 2005 the title of this panel is wrongly given as "Users Mapped to this login" instead of "Databases Mapped to this login"
5. On the bottom select the following permissions

  • db_datareader

  • db_denydatawriter


ReadOnlyUser

Wednesday, July 14, 2010

OleDbConnection String for Excel, CSV and Tab Delimited Formats

Office 2003 and Lower till 97
Excel Format (xls)
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=FilePathWithFileName;Extended Properties='Excel 8.0;HDR=YES;IMEX=1'

csv Format
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=FilePathWithoutFileName;Extended Properties='text;HDR=YES;FMT=CSVDelimited'

Tab Delimited
Provider=Microsoft.Jet.OLEDB.4.0;Data Source=FilePathWithoutFileName;Extended Properties='text;HDR=YES;FMT=TabDelimited'


Office 2007 and 2010
Excel Format (xlsx)
Provider=Microsoft.ACE.OLEDB.12.0;Data Source=FilePathWithFileName;Extended Properties=""Excel 12.0;HDR=Yes;IMEX=2

csv Format
Provider=Microsoft.ACE.OLEDB.12.0;Data Source=FilePathWithoutFileName;Extended Properties='text;HDR=YES;FMT=CSVDelimited'

Tab Delimited
Provider=Microsoft.ACE.OLEDB.12.0;Data Source=FilePathWithoutFileName;Extended Properties='text;HDR=YES;FMT=TabDelimited'

Note For Office 2010 you would need to download
Microsoft Access Database Engine 2010
If this is installed this is backward compatible to read older versions too (xls) so there is no need for having two different connection string.

Since this driver has a 64 bit version, the long standing bottleneck of not able to use the 64 bit CPU architecture is finally solved.

Gotomeeting Outlook Plugin

This plugin is not a stand alone install.

This needs to be installed as part of the entire application.

Navigate to

www.gotomeeting.com

click on "Host a meeting" at the top of the page

This would give a page with a button which says "Launch Software"

This would install the software together with the Outlook toolbar. If you had Outlook opened while the installation was on, you have to restart Outlook to see the tool bar.

Gotomeeting plugin for Outlook

Monday, July 12, 2010

Hyper-V and Diskpart to extend an existing virtual hard disk

Using Hyper-V make sure that the virtual disk is not partitioned. If you want a new partition instead of partitioning the disk create a new disk and add it to the virtual machine.

If however the existing disk space is not enough we may need to increase the disk size using Hyper V Manager

1. Open Hyper V Manager
2. On the list of Virtual Machine make sure the machine whose disk is to be extended is shut down
3. Right click the machine and choose settings
4. On the settings dialog chose the Hard Drive (IDE Controller)
5. Under the Virtual hard disk click on the edit button
6. Under Choose action select expand
7. Under the Configure Disk change the new size to the desired value and save the changes
8. Using the Hyper V Manager Start the virtual machine.
9. If the virtual disk is a partition the newly allocated size would come up as unallocated space in Disk Management
10. We can add this to last partition created on the disk using diskpart
11. Open a command prompt (hopefully with administrative access)
12. Type Diskpart
13. Type list volume
14. Select the volume nearest to the unallocated space in the Disk Management utility discussed previously by giving the command select volume
15. Type extend
The partition would have absorbed the newly unallocated space.

Happy Extending
Anton