Returning a string from unmanaged dll to .net

I write most of my code in unmanaged languages such as Delphi and C/C++. Sometimes I need to interface my code to .net code in which case I create a dll.

A recurring thing is that I need to return string to .net.

There are many ways to do this of course but in all cases we need to manage memory: who will allocate the memory for the string and who is responsible for freeing it?

Read more

DataSet.ReadXML throws DirectoryNotFoundException

Author: Ingmar Verheij

A .NET application that reads a dataset from an XML using the DataSet.ReadXML method might throw the exception : System.IO.DirectoryNotFoundException: Could not find a part of the path ‘<path of XML file>’.

According to MSDN this exception is thrown when when “part of a file or directory cannot be found” .However, this exception is not only thrown when a file cannot be found on the disk. The exception is also thrown when the structure of the XML is invalid (for instance because you didn’t close a node)

Read more

Scripting or programming the Performance Counters

It’s possible to connect to the Performance Counters of a remote machine and retrieve the values of the different counters. But when the local language is different than the one you are connecting to, it will present you the language of the categories and counters of the local machine:

So local machine language is Dutch and remote machine is English, the categories and counters are displayed in Dutch.

This is really annoying when scripting or programming.

You can change this behaviour by changing the CultureSet (

‘Define constants
Const strApplicationCulture As String = "en-US"

‘Set the culture of this application to the specified culture
System.Threading.Thread.CurrentThread.CurrentCulture = New System.Globalization.CultureInfo(strApplicationCulture, False)

Ingmar Verheij & Daniel Nikolic