The Wiert Corner – irregular stream of stuff

Jeroen W. Pluimers on .NET, C#, Delphi, databases, and personal interests

  • My badges

  • Twitter Updates

  • My Flickr Stream

  • Pages

  • All categories

  • Enter your email address to subscribe to this blog and receive notifications of new posts by email.

    Join 2,514 other followers

Archive for August, 2013

Visual Studio: break on all CLR exceptions, not only the unhandled ones.

Posted by jpluimers on 2013/08/29

When you have a layered exception handling (for instance to translate general exceptions into domain or business exceptions, and want to control which exceptions trickle up to where), then from a debugger perspective, most exceptions  actually handled.

However debugging those layers, it often makes sens to be able to break where all these exceptions are actually fired.

The screenshots (click on each to enlarge) are for Visual Studio 2010, but it works in any Visual Studio version and (since it is a debugger feature, not a language one) for all .NET languages I tried so far.

Note that as of Visual Studio 2010, if you disable these, it still breaks when exceptions are thrown from code called through reflection. This seems intentional and has 3 workarounds, but it might have been reverted in Visual Studio 2012.

This is a setting stored on the Solution level (.suo file) in Visual studio which by default is turned off. Luckily, it is very easy to turn this feature on, for instance for CLR (.NET Common Language Runtime) exceptions:

  1. In the “Debug” menu, choose “Exceptions” (or Press Ctrl+D, E),
  2. Wait a few moments for the dialog to appear
  3. Put a checkmark in the “Thrown” column for the “Comon Language Runtime Exceptions” row.
  4. Click the “OK” button. Read the rest of this entry »

Posted in .NET, .NET 1.x, .NET 2.0, .NET 3.0, .NET 3.5, .NET 4.0, .NET 4.5, C#, C# 1.0, C# 2.0, C# 3.0, C# 4.0, C# 5.0, Development, F#, Prism, Software Development, VB.NET, VB.NET 10.0, VB.NET 11.0, VB.NET 7.0, VB.NET 7.1, VB.NET 8.0, VB.NET 9.0 | 1 Comment »

On Windows: Do not install the Android SDK ADT bundle in a path with spaces

Posted by jpluimers on 2013/08/28

Some 20 years after someone thought it was a nice idea to allow spaces in path names on Windows, it still is a bad idea to rely that just “works” for everything.

Today I tried to see if it still applied what I mentioned 2 years ago during the German BASTA! Fall conference in the Rheingoldhalle when talking about cross platform .NET development using MonoDroid/MonoTouch/Visual Studio:

Android SDK
– Windows:
Do not install in a directory with spaces (not C:\Program Files, but C:\android-sdk)

And it does still apply: though not mentioned in the Android SDK/ADT documentation, most of the batch files in the Android SDK ADT bundle are not compatible being stored in a path that has spaces.

Unquoted referrals to paths like this are used in most SDK batch files:

cd /d %~dp0

The only way to run these batch files is with the current directory being the directory of the batch file itself, or referring to them in their fully quoted form.

Another correct way would be to use short names, but that’s only done in find_java.bat:


Summary of the batch files and how they are affected:

+ …\adt-bundle-windows-x86-20130522\sdk\build-tools\android-4.2.2\dx.bat
+ …\adt-bundle-windows-x86-20130522\sdk\tools\android.bat
+ …\adt-bundle-windows-x86-20130522\sdk\tools\ddms.bat
+ …\adt-bundle-windows-x86-20130522\sdk\tools\draw9patch.bat
+ …\adt-bundle-windows-x86-20130522\sdk\tools\hierarchyviewer.bat
+ …\adt-bundle-windows-x86-20130522\sdk\tools\jobb.bat
+ …\adt-bundle-windows-x86-20130522\sdk\tools\lint.bat
+ …\adt-bundle-windows-x86-20130522\sdk\tools\monitor.bat
+ …\adt-bundle-windows-x86-20130522\sdk\tools\monkeyrunner.bat
+ …\adt-bundle-windows-x86-20130522\sdk\tools\traceview.bat
+ …\adt-bundle-windows-x86-20130522\sdk\tools\uiautomatorviewer.bat
– …\adt-bundle-windows-x86-20130522\sdk\tools\lib\find_java.bat
+ …\adt-bundle-windows-x86-20130522\sdk\tools\lib\post_tools_install.bat
* …\adt-bundle-windows-x86-20130522\sdk\tools\proguard\bin\proguard.bat
* …\adt-bundle-windows-x86-20130522\sdk\tools\proguard\bin\proguardgui.bat
* …\adt-bundle-windows-x86-20130522\sdk\tools\proguard\bin\retrace.bat
– …\adt-bundle-windows-x86-20130522\sdk\tools\templates\gradle\wrapper\gradlew.bat
– compatible with spaces in path
+ incompatible with spaces in path
* won't run at all when current directory is different from directory of batch file

view raw


hosted with ❤ by GitHub

(Side note: most incompatible batch files correctly do `for %%i in (“%cd%”) do set prog_dir=%%~fsi`)

So: make sure “…”  is a path not containing spaces.


Posted in Android, BASTA!, Conferences, Development, Event, Mobile Development, Software Development | Tagged: , , , , , , , | Leave a Comment »

.NET/C#: extension method shows what SQL + parameter values are sent to the server (via StackOverwlow)

Posted by jpluimers on 2013/08/28

Every once in a while you are in situation where you are not allowed to use SQL Server Profiler, nor to see any query plans, but you still want see the SQL going from your .NET apps to the database server.

With that SQL, you can feed it through your favourite database tool, and see where the culprit is.

There are various ways of getting rudimentary or a bit more advanced SQL out of this. Flapper posted a solution that is specific for SQL Server (and requries both ObjectExtensions.cs and StringExtensions.cs from the DotNetX library), but posted more ready to use SQL.

I opted – and wanted to hank Justin Harris – for this piece of code on StackOverflow, which works on any IDbCommand (so you can use it for any ADO.NET data provider, like SQL Server, OLE DB, Oracle, etc):

While you will not be able to plug is into something like Enterprise Manager to run it works for logging.

public static string ToReadableString(this IDbCommand command)
    StringBuilder builder = new StringBuilder();
    if (command.CommandType == CommandType.StoredProcedure)
        builder.AppendLine("Stored procedure: " + command.CommandText);
        builder.AppendLine("Sql command: " + command.CommandText);
    if (command.Parameters.Count > 0)
        builder.AppendLine("With the following parameters.");
    foreach (IDataParameter param in command.Parameters)
            "     Paramater {0}: {1}",
            (param.Value == null ?
            "NULL" : param.Value.ToString())).AppendLine();
    return builder.ToString();

answered Apr 12 ’10 at 20:26; juharr

You saved my day! Not being allowed to use the profiler, this is a great way to get the actual SQL, then run it from SSMS or the Enterprise Manager. – Jeroen Wiert Pluimers

I pasted it in a DataExtensions class like this: Read the rest of this entry »

Posted in .NET, .NET 3.0, .NET 3.5, .NET 4.0, .NET 4.5, C#, C# 3.0, C# 4.0, C# 5.0, Development, Software Development | Leave a Comment »

Dutch stop of the RAD Studio in Action LIVE! event: September 7th, Leiden (close to Amsterdam) with extra conference track.

Posted by jpluimers on 2013/08/27

The Dutch stop of the RAD Studio In Action LIVE! tour is on September 7th.

The venue location is via Holiday Inn Leiden Hotels: Haagse Schouwweg 10, 2332 KG  Leiden, The Netherlands.

It is close to the advertised “Amsterdam Netherlands” (about half an hour drive), close to the A44 highway and close enough to public transport. And it is indeed on Saturday September 7, 2013

Full day event: RAD Studio In Action LIVE! + conference track Read the rest of this entry »

Posted in Android, Android Devices, CodePlex, Conferences, Delphi, Delphi XE4, Delphi XE5, Development, DVCS - Distributed Version Control, Event, FreePascal, git, iOS Development, Lazarus, Mercurial/Hg, Mobile Development, Power User, Software Development, Source Code Management, SourceForge, Subversion/SVN, TFS (Team Foundation System) | Leave a Comment »

Windows library search order (EXE/DLL/module) (via “The Old New Thing”) and max PATH length

Posted by jpluimers on 2013/08/27

From The Old New Thing:

Recall that the library search path searches directories in the following order:

  1. The directory containing the application EXE.
  2. The system32 directory.
  3. The system directory.
  4. The Windows directory.
  5. The current directory.
  6. The PATH.

Note that the PATH environment variable has a limited length, which can be impacted by the installation programs you use and the Windows versions you use.

To be on the safe side, use 1024 or 1920.

I found various limitations: Read the rest of this entry »

Posted in Development, Microsoft Surface on Windows 7, Power User, Software Development, Windows, Windows 7, Windows 8, Windows Server 2000, Windows Server 2003, Windows Server 2003 R2, Windows Server 2008, Windows Server 2008 R2, Windows Vista, Windows XP | Leave a Comment »

%d bloggers like this: