Springe zum Inhalt

Auf einer .NET-Informationsveranstaltung habe ich den Begriff DLL-Hell aufgeschnappt. Hier wollte die .NET-Entwicklungsumgebung eigentlich neue Maßstäbe setzen und die DLL-Flut weitgehend verhindern. Fakt ist jedoch, daß aus jedem einzelnen .NET-Projekt eine eigene Assembly (als DLL- oder EXE-Datei) resultiert. Das fehlende Utility ist ILMerge. Mit diesem Utility kann man die einzelnen zum Projekt hinzugehörenden DLL-Dateien in eine einzige Assembly verpacken.

ILMerge is a utility that can be used to merge multiple .NET assemblies into a single assembly. ILMerge takes a set of input assemblies and merges them into one target assembly. The first assembly in the list of input assemblies is the primary assembly. When the primary assembly is an executable, then the target assembly is created as an executable with the same entry point as the primary assembly. Also, if the primary assembly has a strong name, and a .snk file is provided, then the target assembly is re-signed with the specified key so that it also has a strong name.

ILMerge is packaged as a console application. But all of its functionality is also available programmatically. Note that Visual Studio 2005 does allow one to add an executable as a reference, so you can write a C# client that uses ILMerge as a library. If you are using Visual Studio 2003, you must use the v1.1 version of ILMerge and rename it to be a dll in order to use it as a reference.

There are several options that control the behavior of ILMerge. See the documentation that comes with the tool for details.

The v2.0 version of ILMerge runs in the v2.0 .NET Runtime, but it is also able to merge v1 or v1.1 assemblies. However it can merge PDB files only for v2 assemblies. The v1.1 version of ILMerge can only process assemblies built in the v1.1 runtime (but does merge PDB files for those assemblies).

Currently, ILMerge works only on Windows-based platforms. It does not yet support Rotor or Mono. It runs in the v2.0 .NET Runtime, but is also able to merge v1 or v1.1 assemblies. Quelle


Q: How to convert between 'CString' and 'std::string'?


'CString' to 'std::string':

CString cs("Hello");
std::string s((LPCTSTR)cs);

'std::string' to 'CString':

std::string s("Hello");
CString cs(s.c_str());

std::string cannot always construct from a LPCTSTR i.e. the code will fail for UNICODE builds.

As std::string can construct only from LPSTR / LPCSTR, a programmer who uses VC++ 7.x or better can utilize conversion classes such as CT2CA as an intermediary.

Like this:

CString cs ("Hello");

// Convert a TCHAR string to a LPCSTR
CT2CA pszConvertedAnsiString (cs);

// construct a std::string using the LPCSTR input
std::string strStd (pszConvertedAnsiString);

Der mit .NET 2.0 eingeführte Namespace My beinhaltet My.Computer.Audio. Mit den darin enthaltenen Methoden ist es einfach möglich, Audiodateien wiederzugeben:

Dim musicFile As String
musicFile = My.Computer.FileSystem. _
    GetFiles("C:\WINDOWS\Media", _
    FileIO.SearchOption.SearchAllSubDirectories, _

inline unsigned char toHex(const unsigned char x) {
	return x > 9 ? (x + 'A' - 10) : (x + '0');
std::string URLEncode(const std::string &sIn)
	std::string sOut;
	const size_t length = sIn.length();
	for (size_t idx = 0; idx < length;) {
		const char ch = sIn.at(idx);
		if (isalnum(ch))
			sOut.append(1, ch);
		else if (isspace(ch) && ((ch != '\n') && (ch != '\r')))
			sOut.append(1, '+');
			sOut.append(1, '%');
			sOut.append(1, toHex(ch>>4));
			sOut.append(1, toHex(ch%16));
	return sOut;