Archive for the ‘Uncategorized’ Category

Missing MSVCR80.DLL, MSVCM80.DLL, MSVCP80.DLL

Thursday, May 27th, 2010

I ran into a problem yesterday that took a few hours to decipher. I thought I’d share it here, in case Google manages to lead someone with a similar problem this way.

I made a minor change to a DLL in a program I’ve been working on and distributed it to the end users. The user that had requested the fix was happy with the result, and everything was fine for a couple of hours. Then I received an email from another user complaining the program was failing to load, reporting the error

System.IO.FileLoadException: Could not load file or assembly 'MyLIB, Version=1.0.3798.19982, Culture=neutral, PublicKeyToken=null' or one of its dependencies. This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem. (Exception from HRESULT: 0x800736B1)

I’d seen this type of error before; typically it means MyLIB.dll requires another DLL that isn’t present. I checked his program folder, but everything was present – no missing DLLs. Tried re-patching and tried re-installing, and still no luck. I ran the dependency walker to see exactly what it was that it was missing. Turns out to be MSVCR80.DLL, MSVCM80.DLL and MSVCP80.DLL – the MS Visual C++ runtime.

Wait, what?

That didn’t make any sense, as he’d had the program running happily a few hours before. I tried re-installing the runtime, but that didn’t seem to help. Much scratching of heads and gnashing of teeth followed.

It turns out that the new build of MyLIB.DLL that I’d built had tied itself to the specific runtime version I had on my PC – 8.0.50727.4053. These runtime DLLs were installing into C:\Windows\WinSxS, where different versions of the same DLLs live side by side in an uneasy truce. I don’t pretend to fully understand what’s going on in there, but anyway. The different versions of runtimes were in different subfolders, the names of which contained the version number. When we checked the machine that the program was failing to run on, the .4053 version wasn’t there. We had to find that specific C++ redistributable version on microsoft.com as install it, which fixed the problem. The version of the runtime I had tried reinstalling earlier was an older version. It was then I realized that I have a new PC, and this is the first time I’ve rebuilt that particular DLL on this machine. Those with older machines were less likely to have the newer runtime installed.

Many sources on the interwebbings were simply saying “get the dll from here, and stick it in your Windows\System32 directory”. This is exactly wrong in this instance.

It would be nice if I could find an option in the project build configuration that says “Use runtime version X or later”, rather than it requiring the specific version it finds on my machine.

ImageList and .NET leaks

Wednesday, April 14th, 2010

Even with garbage-collected managed memory systems like those found in C#/.NET applications still suffer from leaks.

Most of the time, the “leak” is an object that has a reference to it being held by a static object. These can be a pain to identify, and near impossible in a large application without the aid of additional memory tracking tools. SciTech’s .NET Memory Profiler software is such a tool, and has proven itself invaluable in detecting these problems.

It surprises me how often leaks come back to (mis)use of the innocent looking ImageList object. For example, I have an ImageList object that contains a set of icons for different document types, and use it for ListViews, TreeViews, and anywhere else in the UI where I’m presenting collections of documents. It’s all too easy to set the image list:

myListView.SmallImageList = MyApp.DocumentIcons;

…then assume that when this particular UI goes away, all the contents go away too.

Under the surface, pointing a ListView control at an ImageList also causes the ImageList to store a reference back to the ListView. This way, if an icon is modified in the ImageList, all the ListViews and other controls that are using it can be updated too. The downside is when you forget to reset the SmallImageList property in the ListView control when the control containing the ListView is being disposed. Because the ImageList refers to the ListView, the ListView won’t go away. The ListView refers to the parent UI, the parent UI refers to the document, the document refers to the data, and so on. So when we set our document reference to null, while we might expect the whole lot to be disposed, they continue to persist in memory,  accessible only through the ImageList object.

SciTech’s tool allows me to take snapshots before and after opening and closing a document or particular UI, and compare them to see what objects have been created but not freed. I’ve been using it for a few days and have already found a couple of commonly used UserControls in a UI-heavy application that weren’t being disposed of correctly.

Natural order

Wednesday, February 24th, 2010

Being a parent is an awesome responsibility. The choices and guidance I provide to my kids now can have a huge impact on the adults they become. Sometimes this can be daunting, especially when you realize you only have one shot at some elements.

One such element is something I’ve been wondering about for a while now. I’ve asked a couple of people for input, and for the most part, they just laughed. I don’t think they realize the magnitude of the issue. So here it is:

In what order should we watch the Star Wars films?

Should we go for released order, i.e. New Hope, Empire Strikes Back and Return of the Jedi (the original trilogy), then episodes  1-3? This was the order I grew up with. This way, you get the surprise that Darth Vader is Luke’s father. This is what I’m familiar with.

Alternatively, we could go in story order, with episodes 1-3 first.  It’s impossible for me to truly understand how the original trilogy will be interpreted already having the back story of episodes 1-3, beyond superficial observances like half way through the story, the effects are toned way down and suddenly there are characters running around the films.

You’re laughing at me now, aren’t you?

Binary Thumbs

Wednesday, February 24th, 2010

I tried playing Halo 3 the other night. Oh dear.

I thought I’d start off gradually and selected difficulty mode “Easy”. “The game practically plays itself”, claimed the description of the easy mode setting. Nevertheless, I still managed to die.

Now, ok, I should have been wearing my glasses. My original comfy seat on the sofa, about 10′ away from my 40″ tv, was quickly replaced by perching on the edge of a seat about 3′ away, but still my right eye was tearing from trying to make sense of all the detail. But never mind all that. The ultimately frustrating thing about the game I found was the controls.

For those who have never played, it seems that the left analogue stick controls movement left/right/forward/back, while the right analogue stick turns you left/right and causes you to look up and down. These are all pretty crucial when trying to shoot some alien creature ducking behind a tree, 20 yards in front of you. That’s kind of what the game is about.

I’m afflicted with the terrible physical disability thumbus binaris – possibly as a result of hundreds of keyboard based games and over exposure to Playstation 1 games. My thumbs don’t do analogue. It’s left or right or nothing. There’s no slightly-little-bit-to-the-left-but-not-too-much, often required to nudge the sights just past the edge of the tree ready for the alien. No, I swing around at full force like a drunken muppet on ice. And usually while staring at the sky or the ground, leaving me wondering where the heck I am now.

This isn’t a new discovery. I seem to remember having the same kind of “fun” with Goldeneye on N64. This may also explain why I’ve been less inclined to invest in PS2, PS3 or XBOX gaming, compared to PC games. I’m ok with a keyboard and mouse.

Am I getting too old for these games? Maybe I should just quit whining and try it again.

I’m certainly not going to venture online in this game just yet!

Groundhog Day

Tuesday, February 9th, 2010

Last week was Groundhog Day, and almost inevitably, Bill Murray’s Groundhog Day movie was showing on TV. It reminded me of articles I’d read last year, where the author attempted to work out how long Mr Murray spent repeating the same day over and over, by estimating the time required to learn to play a piano, speak French, etc. Opinions differ, ranging from 8 to 40 years. Either way, this is a seriously long time.

Even at the low end of the scale, I imagine 8 years would be enough time to get over the horror of the situation and accept the new lifestyle. It has it’s advantages for sure. Most importantly, you’re presented with potentially unlimited free time to spend doing whatever you want. Although you can’t take anything physical along with you day to day, knowledge and skills persist, so you can learn to play instruments, speak new languages, learn how to paint. I guess if you can get to an airport, you could learn to fly, too – especially as any fatal crashes are resolved at 6am the following morning.

There’s a ton of things you no longer have to worry about. You don’t have to worry about going to work any more. You don’t have to worry about money – your bank account replenishes every morning and you can always rack up credit cards without worrying about repayments. You don’t have to worry about mortgage payments or utilities. You can eat or drink whatever you want, seeing as your body also resets every morning – yay, no hangovers! You don’t have to worry about illnesses or crime, and you can be secure in the knowledge that everyone you care about is safe because the world resets every morning.

Sounds appealing* when you think of it like that.

Now imagine you’ve spent 8, 10, 20, or 40 years like that, and suddenly you get snapped out of it into a normal timeline. All those worries come back in a flash, and you’re not ready for it. Suddenly, you have no idea what’s going to happen that day, and now your actions have consequences.

I think that’d scare the life out of me. I picture Bill Murray wandering out into the snow covered street after the end of the movie and suddenly realizing, potentially for the first time in decades, that he has no idea what it going on in the town around him.

“Aaaaaaaaaargh!”

* Ok, the downsides might balance this out a bit. It must get pretty lonely after a while when no-one remembers the previous day’s interactions and you can’t talk about anything you’ve been doing without them thinking you’re crazy.

Caprica, disbelief unsuspended.

Wednesday, February 3rd, 2010

I watched the second episode of Caprica last night. This is the prequel to Battlestar Galactica, tracing the development of the Cylons. So far, I’m enjoying it, but in this episode I noticed something that kind of broke the suspension of disbelief.

It wasn’t the appearance of the Cylon prototype. There is something that’s not quite right about the CG animated Cylon; it doesn’t seem to settle in the scene like it’s actually there. I can’t put my finger on what’s wrong, though. Maybe it’s rendered too shiny? Maybe it’s too sharp in contrast to the rest of the scene? Maybe there’s something wrong with the animation – not weighted correctly, perhaps? Maybe the appearance of an eight foot tall battle robot sitting in a teenager’s bedroom is just not right to start with.

But no. The thing that caught my eye was this:

A VGA cable in the back of a monitor in the lab where they’re working on the Cylon.

Elsewhere in the show they have video playing on the interior surface of house windows. They have video playing on a sheet of paper. Super hi-tech stuff. But down in the lab, they have a monitor with a familiar blue VGA connector plugged in the back. I wouldn’t be surprised if there was a Dell logo on the front.

It brought me right back down to Earth, in all senses of the phrase!

Alright, I’m a nerd.

XBOX 360 Networking

Tuesday, February 2nd, 2010

Recently, I got an XBOX 360 system. Setting it up to access the internet via my wireless router was a lot more hassle than I was expecting. It certainly wasn’t the “plug and play” experience that was mentioned in the blurb.

The wireless network has been up and running for quite some time. A Linksys WRT54G router, running DD-WRT, has been happily servicing connections from a laptop, Nintendo Wii and iPod Touch for nearly a year. None of these needed any special coaxing to get connected; simply select the network, enter the password and off we go.

I naively expected the XBOX to work the same way. Let’s overlook the fact that the wireless network adapter is an “optional” extra, costing $100 (or $30 after discounts from newegg). $100 seems a little extortionate, considering the Wii has this built in as standard, but I said I would overlook this. In the box was the adapter and a driver disk.

Installing drivers on a console seems a little alien to me. The Wii is only other console I’ve had that has anywhere to copy drivers to, and I guess any driver installations/updates have been hidden in system updates on game disks or downloads. Anyhoo, the booklet says to power up the system, insert the driver disk and the installation will start.

I power up the system, insert the driver disk and wait. And wait. And then realize that despite what the manual says, this disk isn’t going to auto-run. Resetting the system with the disk in the drive spurs it into action.

Having installed the drivers, the manual then says to plug in the adapter, and follow the on-screen instructions for setting up the network connection. I plug mine in, and don’t see any of the promised instructions pop up. I have to dig into the console settings and network config options. I select my wireless network and enter the password. It tells me it’s connected. Premature celebrations end abruptly when I realize it’s totally failed to retrieve an IP address from the router, and so can do nothing with the connection.

It’s the only device so far that’s been unable to retrieve an IP address, so I’m not convinced this is a router issue. Regardless, I try resetting the router and reconnecting the XBOX, and still it fails to fetch an IP address. I give up and manually assign it an address and explicitly point it at the router. More success. I can now connect to the internet and see other computers on the network.

I now try to redeem my 12 month XBOX Live gold membership code. Let’s overlook that it costs an additional $50 a year to get online with my $100 adapter, or $30/year if Walmart’s online store is in stock. Apparently, although I’m connected to the internet, I can’t connect to XBOX Live. The test option in the networking options is displaying a little warning sign and it’s telling me my NAT is Moderate.

My NAT is Moderate? It might as well tell me my NAT is purple for all that means.

Googling Moderate NATs brings me to a few XBOX forums, filled with the cries of other people who also apparently have Moderate NATs. Thankfully, amongst the multitude of offered solutions which barely stopped short of chicken sacrifice, the following gems were nestled:

On the router, set up port forwarding to the XBOX:

Port 3074, udp/tcp

Port 88, udp

Once this was done, another connection test revealed my NAT was no longer Moderate, and connection to XBOX Live was now possible.

I’d like to think that from here on out, everything would work happily. Not quite. Whenever I turn the console on and attempt to log into my XBOX Live account, it tells me it’s unable to connect. When I test the connection, it connects without problem, then I can go back and continue to log in, successfully this time. This isn’t the end of the world, but it’s annoying.

Connecting to Windows Media Center on my desktop PC is also troublesome. It works, it’s just unusably slow. Streaming works fine, it just takes maybe 30 seconds or so to react to the controller when navigating the menus. More googling reveals some tweaks to the network settings on the desktop PC. I’ve tried switching the connection speed from “auto” to 100MB full duplex to see if that makes a difference. I’ll try it tonight and see if that helped at all!

Netbeaning it again

Friday, September 19th, 2008

I ran across this comment today:

[...] on more complex forms, [the Matisse GUI editor] becomes unbelievably frustrating and time-consuming. It tries to be too intelligent about what it thinks you want to do and often just moves things around wildly when trying to do simple adjustments or additions of components.

and another comment further down:

I’ve spent hours trying to get the layouts I want with it and it seems to be more trouble than it’s worth sometimes. Sometimes it insists on stretching and stretching my forms.

By this time, I’m banging on the desk shouting “Yes! That’s exactly what I’m seeing!”. Further down still:

About the Matisse problems; they rely on the layout. try changing the layout to NullLayout

Oooh, of course. That makes perfect sense.

One downside is that you need to do this before you start. I tried changing it on a complex window layout I’d manage to coax together, and it promptly collapsed all the controls into a heap. But I tried playing around with it in a test window and sure enough, I was able to drag around and place controls wherever I wanted without the annoying repositioning and resizing of other controls.

Apparently, I also lose some other features in this mode. Exactly what, I’m not sure, as I’ve only had a few minutes to play around with it. Maybe some of the fancy alignment tools have gone. I can probably live without that.

Look ‘n’ feel

I finally got my app running far enough to show me my window layout in all it’s glory. I was startled to see that the Windows XP appearance of the controls that I see in the GUI editor have been replaced with java-rendered equivalents. This is exactly what didn’t happen with the test application I made to make sure that this sort of thing wouldn’t happen. I’ve been hunting around in case there’s an option hidden somewhere that causes it to render controls in the native-OS form. No luck yet. I’m not sure what the difference is between my test app and the main app. Maybe it’s because I started the test app as a Java Desktop Application, whereas the main app started life as a JOGL app, and got additional windows added in.

I daren’t go any further with this until I see how it looks on a Mac. If I need to rebuild the app as a desktop app with JOGL window added in, I want to make sure that looks right on a Mac before I get too far down the path.

Netbeans 6

Saturday, August 9th, 2008

So I’m converting a C# app to Java and I’ve decided to use Netbeans as my editor. It’s been a while since I played with Netbeans, and last time I played with it, I didn’t really do anything major with it. Now I’ve got version 6.1 installed and this time I’m giving it a bit of a workout.

On the whole, I’m liking it. I started by creating a test application with a swing based window and OpenGL rendering, which forms the basis of what I’m aiming to do with it. Getting the OpenGL bindings – jogl – installed and linking was half google and half trial-and-error. It also took a little research to get the Java API docs downloaded and recognized by the IDE, but they’re there now.

Programming in Java is not something I’m terribly used to. I worked on J2ME programming for cell phones a few years ago, which seems worlds away from write J2SE apps for a desktop computer. The cell phones we were targetting at the time had so little space for the jar files that we had to think twice before creating a new class because of the additional jar space it would require. Oh, and I have floating-point arithmetic now, which is nice.

I’m starting with an almost line for line conversion of the C# app, which means cutting and pasting the code into Netbeans, then massaging it until all the red underlines disappear. A lot of this is pretty mindless (good for me!), e.g. a C# property Value { get; set } turns into a Java getValue() and setValue(). Netbeans feels sluggish compared to MS Developer Studio, but Netbeans also points out compile errors as you’re writing, rather than discover them at compile time. The Netbeans auto-completion functionality seems a bit too intrusive. Often I’m coming to a jarring halt in mid flow because it’s auto-completed something I wasn’t expecting and it takes a second or two to make sure I’m not ending with doubled code. It’s probably configurable, and seems intrusive because I’m not used to it.

One of the major changes to the app is the windows interface. The original is all built in C#/.NET Framework 2.0, and I’m re-implementing this using the swing toolset. This is where we come to Netbeans’ GUI designer.

Oh my life.

Initially, I thought it was pretty cool. Placement of controls within the window seemed pretty easy and the guides snapping controls into positions with reasonable borders and spacing seems superior to the GUI designer in Developer Studio. Great, I thought, this is going to take no time at all. Famous last works.

As the window contents became more complicated, strange things began to happen. I’d have five buttons in a row and go to add a sixth. When I try to position the sixth, a couple of the other five pop down the window by some random quantity, stretching the container. I try to push them back into position, but one won’t go. Every time I try to reposition it, it pops down by a bit more, again stretching the window.

When I was first using Microsoft’s gui designer, I found it to be an exercise in frustration, mainly because I didn’t fully understand the docking and anchoring mechansisms, and control orders, and being stuck with the old 1.1 .NET Framework and DevStudio 2003. The 2005 editor is much improved, and understanding how the window system works helps a great deal. I’m hoping there’s a similar trick to the Netbeans system, that some day it will suddenly make sense!

Maybe I need to rely more on frames – keep a minimum of controls within a frame, and use many frames to build the whole window.

Maybe I need to play around with the layout manager a bit more. I think that’s what it’s called. Seems to responsible for how controls are laid out within a container. There’s a particular mode that sounds like it allows completely free-form placement of control, which is what I’m expecting, but apparently requires an additional component to be added and distributed with the app.