dotnet thoughts 

a dotnet developer's technical blog

Debugging NUnit Tests in Visual Studio 2010

If you are using NUnit with .Net 4.0 assemblies in Visual Studio 2010, while debugging, you will get this warning from breakpoints locations, “The breakpoint will not currently be hit. No symbols have been loaded for this document”

The breakpoint will not currently be hit. No symbols have been loaded for this document

The breakpoint will not currently be hit. No symbols have been loaded for this document

This issues is because of NUnit loads up in .Net 2.0 and then has to load up the modules in 4.0, so does so under the agent process. The solutionis to force NUnit to run under .Net 4.0. This will can done by modifing the NUnit.exe.config file.

<startup>
	<requiredRuntime version="v4.0.30319" />
</startup>

This will fix the issue, also you are able to debug with breakpoints. If you are running Windows 7, make sure you are opening the NUnit.exe.config file as Administrator. And if your OS is 64 bit, you should modify nunit-x86.exe.config file.

Happy Unit testing :)

Open Visual Studio Files As Administrator

Debugging WCF service requires to run the visual studio as Administrator, you can do it by right clicking the Visual Studio shortcut, Select Properties, and in Shortcut tab, click on Advanced button, it will display Advanced Properties, check the Run as administrator option.

Advanced Properties

Advanced Properties

But this option will not work, when you are opening a project or solution by double clicking on the solution file. Here is the tip which will help you to open Visual Studio files with Administrator option. All the solution files are opening using a small utility called VSLauncher.exe, which can be found in C:\Program Files (x86)\Common Files\microsoft shared\MSEnv folder. Right click on the executable, select Properties and select the Compatibility tab, Check the Run this program as an Administrator, under Privilege level. Apply the settings and click OK. Now open any solution, Windows will show the UAC dialog.

VSLauncher.exe Properties

VSLauncher.exe Properties

Windows 7 SDK Installation success or error status: 1603

Today my team lead asked me to install FxCop 10 for static code analysis(which is available as part of Windows 7 SDK.) in our projects. As I am using Visual Studio Professional edition, the inbuilt option for Static code analysis is not available. I downloaded the Windows 7 SDK ISO from http://www.microsoft.com/download/en/details.aspx?id=8442 link. And I am able to start the installation. After some time, I got a wiered error like the following -

Windows 7 SDK - Installation Error

Windows 7 SDK - Installation Error

After checking the log file I found a line like this. Installation success or error status: 1603. I searched for this particular error and it was a generic error, sometimes it was related to low disk space. I tried the installation serveral times and everytime I got the same error. Then I modified the installation options, I un-checked all the VC++ related options; which is not required for me. And its worked :) Later I found some problem with the VC++ compiler options and Microsoft has released a patch for it. And you can down load it from http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=4422

Happy Coding :)

How to fix Error Code 29506, While installing SQL Management Studio Express on Windows 7 x64

Today I started installing SQL Server Management Studio express on my Windows 7 x64, and I started installing it, after few seconds, I got an error message like this

This installer has encountered an unexpected error installing this package. This may indicate a problem with this package. The error code is 29506

Error Code 29506, While installing SQL Management Studio Express on Windows 7 x64

Error Code 29506, While installing SQL Management Studio Express on Windows 7 x64

My initial thought was may be it is because of some problem with my downloaded installer. I downloaded it again and still the problem exists. Then I tried it with commandline(cmd), with Run As Administrator option and its worked :)

How to use TaskDialog API in C#

The TaskDialog API replaces MessageBox. A message box is useful for prompting users for an acknowledgment, confirmation, or an answer to a yes or no question. Message boxes are popular because of the MessageBox function is convenient for developers to use. TaskDialog is the preferred API to use because it is similar to MessageBox but much more flexible. Previously, developers have created their own message box implementations when greater functionality was required. Unfortunately .Net framework doesn’t expose TaskDialog API directly; you need to use WIN32 api for it. Here is one Task dialog implementation in C#. Only limitation of Task Dialog API is it doesn’t supported by Windows operating systems less than Windows Vista.

Here is the API declarations.

[DllImport("comctl32.dll", CharSet = CharSet.Unicode, EntryPoint = "TaskDialog")]
static extern int TaskDialog(IntPtr hWndParent, IntPtr hInstance, String pszWindowTitle,
String pszMainInstruction, String pszContent, int dwCommonButtons,
IntPtr pszIcon, out TaskDialogResult pnButton);

//Dialog buttons
[Flags]
public enum TaskDialogButtons : int
{
    Ok = 0x0001,
    Cancel = 0x0008,
    Yes = 0x0002,
    No = 0x0004,
    Retry = 0x0010,
    Close = 0x0020
}

//Dialog Results
[Flags]
public enum TaskDialogResult : int
{
    IDOK = 1,
    IDCANCEL = 2,
    IDRETRY = 4,
    IDYES = 6,
    IDNO = 7,
    IDCLOSE = 8,
    NONE = 0
}

//Dialog Icons
[Flags]
public enum TaskDialogIcon
{
    Information = UInt16.MaxValue - 2,
    Warning = UInt16.MaxValue,
    Stop = UInt16.MaxValue - 1,
    Question = 0,
    SecurityWarning = UInt16.MaxValue - 5,
    SecurityError = UInt16.MaxValue - 6,
    SecuritySuccess = UInt16.MaxValue - 7,
    SecurityShield = UInt16.MaxValue - 3,
    SecurityShieldBlue = UInt16.MaxValue - 4,
    SecurityShieldGray = UInt16.MaxValue - 8
}

And here is my TaskDialog wrapper function.

public static TaskDialogResult Show(IntPtr handle, string messageTitle, string mainTitle,
    string mainContent, TaskDialogButtons taskDialogButtons, TaskDialogIcon taskDialogIcon)
{
    TaskDialogResult buttonClicked = TaskDialogResult.IDCANCEL;
    TaskDialog(handle, IntPtr.Zero, messageTitle, mainTitle, mainContent,
        (int)taskDialogButtons, (IntPtr)(int)taskDialogIcon, out buttonClicked);
    return buttonClicked;
}

And here is the screen shot of Task Dialog running in my Windows 7 machine.

Task Dialog - On Windows 7 machine

Task Dialog - On Windows 7 machine

« Newer PostsOlder Posts »