dotnet Cologne 2012

May 5th, 2012

Today I visited the Event dotnet Cologne 2012. The community feeling was impressive again, the sessions very informative. Coming back with much of impressions outside .NET (!), I will take a look at jQuery mobile next week…

DNUG DD 20120301

March 3rd, 2012

Yesterday I had the chance to give a speech at the .NET User Group Dresden. The topics were:

  • Deeplinking from a Web Form to a Windows Form using a Custom URL Protocol
  • Message Exchange between .NET Processes using WndProc

Download Code Samples here: UG_20120301_code.zip

Download Slides here: UG_20120301.pdf

Thanks to my employer InQu Informatics GmbH for room and catering.

 

(for those who know: shop://component=Bestellungen;id=2 )

Update: Dude, where is my decompiler?

February 23rd, 2012

Middle of February this year, Telerik released its .Net decompiling tool JustDecompile as a final version. I mention this here as an addition to my former Post Dude, where is my decompiler?. JustDecompile comes free also for non-private use. Furthermore it has some interesting out of the box features like creating .csproj-files based on the decompilation.
As a fan of open source, I will continue to use ILSpy. Anyway, JustDecompile is a good to know alternative!

Outside .Net: Microcontroller Programming

February 12th, 2012

This Saturday I visited “Arduino – OpenSpace“ in the rooms of CoFab - CoWorking by ObjectFab. In a friendly and creative atmosphere, we spoke about Microcontroller Programming based on Arduino platform.

For me (that had nothing to do with electronics since study) it was very interesting to see what fun electronic handicraft work can make if you know how to do. So my first project will be a build traffic light coupled with our Team Foundation Server (of course I will write a blog about that soon Smiley mit geöffnetem Mund ).

Some useful links:

CoFab, sponsor of the Event

Project Page of Rene Heller and Thomas Goepfert (Led Globe, Led matrixes)

Homepage of Jörg Pohl (cool things for doing electronics)

(Picture taken from http://arduino.cc)

Sample Texts | Lorem ipsum

November 25th, 2011

For UI-Design it is often helpful, to have some dummy-texts showing the look&feel of the UI close to reality. This requirement goes even back to the 16th century to provide filler texts for typesetting. Here are two links to this topic. The first one links a site I often use for automatic generation of these texts.

Lorem ipsum Generator
Explanation @ Wikipedia

Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.

Get MSI content without installing

October 15th, 2011

Creating setup files is part of our Continuous Integration Process. However, in some very special cases it is necessary, that content of MSI-Files is checked manually (e.g. correct customer specific configurations). To avoid installing the MSI on my Dev Machine, I extract it via command line as described by Aseem Kishore here.


sample:

msiexec /a c:\temp\foo.msi /qb TARGETDIR=c:\temp\foomsicontent

msiexec: Microsoft Windows Installer (command line)

/a: use Installer in administrative mode. It is used to “install” content in a network to allow different users to access it. We can use that to “extract” the content to a local folder.

c:\temp\foo.msi: placeholder for the msi to extract

/qb: “q” ist the parameter for defining the UI mode. “b” defines basic user interface. Using “n” for no user interface makes it attractive for automated processes.

TARGETDIR: one of many properties available in msiexec. Use it for setting the extraction target directory.
c:\temp\foomsicontent: placeholder for the msi extraction target


some related links:
Command Line Reference @ Microsoft TechNet
msiexec Property Reference @ MSDN
Original Post @ thebackroomtech

Dude, where is my decompiler?

March 31st, 2011

Some time ago, well-known .NET Reflector (R) became a paid-for product (see product site). Although a license doesn’t cost very much, a solution for free is prefered by many of us… :D


One possibility is to use Microsoft .Net Intermediate Language Disassembler (ildasm.exe) that is included in the .NET Framework SDK. The tool disassembles .NET assemblies, shows their internal structure, the CIL-Code behind and some assembly related meta information. Cannot find it on your hard drive? Look HERE for some information, where to find it.


Another possibility is to use the open source project ILSpy that is part of SharpDevelop. The tool provides equal features as ildasm does. Additionally it is able to give out the decompiled Code in C#, not only in CIL. This is much easier to read and understand (and to re-use… :D ). Furthermore navigation within class hierarchies is possible and some other nice features that makes decompiling suitable.

DNUG DD 20110119

January 20th, 2011

Yesterday, .NET Usergroup Dresden had its first meeting this year.




Martin Hey gave us a very interesting lecture about Reactive Extensions for .NET (Rx). I already dealt with it some days before. I am looking forward to use this framework in my next real world service consuming components.




Second Daniel Grund gave us an insight into WebMatrix, Microsofts tool for creating and deploying websites. It was interesting to see, how easy website develpment can be: create, customize, publish. :D In my opinion, it is a possible solution for customers that only wants a little website without large customization requirements and thereby without high development costs. WebMatrix doesn’t address high scalable and customizable web projects. So many features that are required for professional software development are not included. Therefor it is no alternative to Visual Studio. But as I mentioned before, to be an alternative is not the requirement…




To have a look at the code samples and the slides, have a look at Martins Blog.

A closer look to temporary files

January 1st, 2011

Everybody developing with .NET knows the method Path.GetTempFileMethod. This method creates a zero-byte file in users temp directory and returns the full path of it. Sample code (seen in similar ways in many production environments) may look like this:

using System.IO;

public class Foo
{
	public void Bar()
	{
		var tempFileName = Path.GetTempFileName();
		using (var fileStream = File.Open(tempFileName, FileMode.Open))
		{
			// do something
		}
	}
}

In this little sample, there are some points of failure, that might not be clearly at all
(by the way: if you read this and you find some other potential sources of errors that should be discussed, tell me by commenting this article):

# Path.GetTempFileName throws an IOException if no temporary file can be created. This might be the (improbable) case if the currently used account has no rights to create files in its temporary folder. But a common case for that is, that no file can be created because the range of temp file names is gone. Path.GetTempFileName internally uses GetTempFileName Function of kernel32.dll. According to the functions unique file name creation algorithm, it is not suggested for creating large numbers of temporary files (as also said in its MSDN documentation). In the way the kernel function is used by the .NET method, only 65535 unique file names can be created. In production systems this might be not enough. So keep this in mind, when you use Path.GetTempFileName.

# Path.GetTempFileName not only creates a unique file name, as the name of the method suggests. It also creates a physical file. This is “only” required to reserve the unique file name. After that, something is done with that file, e.g. opened. As you can see, hard disc gets accessed two times. First for file name creation, second for working with that file. In my opinion, the first access should be avoided… (I know, this is a very little detail. But a penny saved is a penny got… :D )

# Deleting temporary files after working with them should be obligatory. Real world tells us, that this is hardly done (look at the waste in your temp directory…). Also in the upper sample deleting doesn’t take place. So it will run into an exception by the 65536th run at the latest, because there are only 65536 available temp file names.


To solve the mentioned issues, I wrote a little class:

using System;
using System.IO;

namespace FileStreaming
{
	public class FileStreamWithAutoDeletingFile
		: FileStream
	{
		private readonly string _FilePath;
		private FileStreamWithAutoDeletingFile(string filePath, FileMode mode, FileAccess access)
			: base(filePath, mode, access)
		{
			_FilePath = filePath;
		}

		public static FileStream CreateNewTempFileForReadWrite()
		{
			var tempFileName = CreateTempFileName();

			return new FileStreamWithAutoDeletingFile(
				tempFileName,
				FileMode.Create,
				FileAccess.ReadWrite);
		}

		private static string CreateTempFileName()
		{
			/* in legacy implementation: Path.GetTempFileName()
			 */

			var tempDirectory = Path.GetTempPath();
			var fileName = Guid.NewGuid().ToString() + ".tmp";

			return Path.Combine(tempDirectory, fileName);
		}

		protected override void Dispose(bool disposing)
		{
			base.Dispose(disposing);

			try
			{
				if (!File.Exists(_FilePath))
				{
					return;
				}

				File.Delete(_FilePath);
			}
			catch
			{ }
		}
	}
}



It may be used like this:

public void Bar2()
{
	using (var fileStream = FileStreamWithAutoDeletingFile.CreateNewTempFileForReadWrite())
	{
		// do something
	}
}



FileStreamWithAutoDeletingFile has a public method called CreateNewTempFileForReadWrite. This method creates a new file with a GUID based uniqe name and returns a stream for read/write access. When the stream gets disposed, the temporary file automatically gets deleted. This little helper solves all the upper issues: no more naming conflicts, no unnecessary hard disc access and no waste on the hard disc. All encapsulated nice and easily. :D


Happy New Year!

The Bridge

December 19th, 2010

Today I do not want to write about software, therefore also not about the Bridge Pattern, as the title of this post suggests. :D One of germanys most discussed, and therfore very famous construction sites today was the place of excursions for many inhabitants of Dresden and surrounding: the Waldschösschen Bridge (DE/EN). The middle piece of the bridge got positioned, so that its shell now is completely! Such events are very rare, so that everybody (equal if supporter or anti) wantet to see it. For those who were not live present, here a little picture of it…

Anyway, if you want to read something about the Bridge Pattern, see for example this article on THE CODE PROJECT :D .