Category Archives: bug

WIX 3.5 – error LGHT0001: Unable to load DLL ‘winterop.dll’

It has been a while, but here I am again ;) … I am currently working on an old Visual Studio 2005 solution. This bugger used to be built by a build server, but that one died about a year ago. Since some bugs really needed fixing, I decided that I would build the project myself for the moment.

Problem was that the solution uses WIX 3.0, and I have WIX 3.5 installed on my machine. After converting the WIX projects I expected the project to build without any problems. Unfortunately, however, WIX crashes with the following error: error LGHT0001: Unable to load DLL ‘winterop.dll’: The specified module could not be found. (Exception from HRESULT: 0x8007007E).

After some searching on the web I found a post (not entirely my problem) with the searched solution: add the installation path of WIX to the Path variable. After this workaround everything works like a charm. Hope this helps you too ;) !

Happy coding!

The using statement and XmlReader.Create

Are you also fond of using the using statement (e.g. when dealing with streams)? I am, since it kind-of guarantees me that streams are closed when I think they should be closed, even if I do not specify the Dispose() command. You probably noticed the ‘kind-of guarantee’ part. You are right, this is not always the case. It took me a while to find out the the following is not going to work as smooth as expected:

using (var reader = XmlReader.Create(File.Open(fileName, FileMode.Open)))
    { ... }

You probably wonder what’s the problem of the code printed above. I don’t see it too, however, I know there is a problem related to this code. The problem lies in the Create overload used in the example code. It uses default XmlReaderSettings. Unfortunately, this settings do not include having the CloseInput property set to true. You can do the math: no closed file at all! That’s a guarantee for having troubles on the file ‘being in use already’.

The solution to this problem is quite simple:

using (XmlReader reader = XmlReader.Create(File.Open(path, FileMode.Open),
         new XmlReaderSettings { CloseInput = true })) { ... }

How can we call this? A ‘bug’? No, at least not technically spoken. Since the XmlReader creates the stream, it should close it too. The case is, you should not expext it knowing the using statement as most people know it (fail-proofing your code). Since I know this, I am a little bit scared about using using statements without calling the stream’s constructor. You can do so, but be sure it does what you expect it to do… In my opinion, the using statement still remains very helpful, please I do not consider it being as perfect as I thought it to be for years ;)

Solution: The operation could not be completed. Invalid FORMATETC structure

This morning I ran into a ASP.NET bug in Visual Studio. Dragging a custom server control on an aspx file was not possible since I had ‘an invalid FORMATETC structure’ (what the …. is that?!). The message box alerting me something is really really wrong is this one:

The FORMATETC bug

Trying to solve the bug, I  found the following attribute to be the problem: [ToolboxItem(true)]. Just delete the attribute, rebuild the application and the problem/bug disappears!

Good luck! Happy coding!

Visual Studio 2005 and the vaporized Immediate Window

Today I reinstalled my development virtual machine. For a couple of ‘legacy’ software packages I must have Visual Studio 2005 installed as well. Debugging one of those software packages mentioned above, I wanted to ‘hack my runtime’ using the Immediate Window. It wasn’t there!
Since I always have the Immediate Window activated, I cannot remember the shortcut for it (Ctrl+Alt+I :) ). Looking for the menu item to activate it (yes, of course, in the Debug menu) it appeared to be gone. Sadly this is a known bug. The only way to get it back into the menu is using the Tools menu, click Customize, select the Commands tab, choose for Debug commands and drag Immediate onto the toolbar.
For some kind of overview:
I simply assume nobody likes it either :)