Tuesday, March 31, 2009

Unable to create registration information for file named 'filename'?

I have a class library that is written in C# and I have been maintaining for a few years, which contains a COM component. The accompaning class library installer, created using a Visual Studio deployment project, is suppose to deploy and register this COM component and tlb file.

The deployment project was first created using VS2003, then upgraded to VS2005 and finally to VS2008 last year. All of this was done on my Windows XP development machine and, like I said, this has been working for years.

A couple of months ago I upgraded my development machine, reformatted the hard drive and installed Windows Server 2008. After that my COM component doesn't get registered anymore and I get a warning when building my solution. The warning goes like this: "Unable to create registration information for file named ''".

I searched the web for a long time and finally found it at Microsoft Connect, the Microsoft bug tracker, filed as Bug 356321. However, they have Closed it as Fixed but there is still no solution to be found and the deployment project will not work unless you follow the manual workaround provided. I don't like manual work :-)

So I decided to go another way. I have implemented a Custom Action for my installer, which accepts a name of an Assembly, expects it to be installed and will run RegAsm on it. I then refer to the installer like this:



But the code of the installer goes something like this:

[RunInstaller(true)]
public partial class RegasmInstaller : Installer
{
public override void Install(IDictionary stateSaver)
{
base.Install(stateSaver);
string assemblyname = Context.Parameters["ASSEMBLY"];
if (assemblyname != null)
{
Assembly asm = Assembly.GetExecutingAssembly();
string asmName = asm.Location;
int bsIndex = asmName.LastIndexOf("\\");
string asmDirName = asmName.Remove(bsIndex, asmName.Length - bsIndex);
bsIndex = asmDirName.LastIndexOf("\\");
asmDirName = asmDirName.Remove(bsIndex, asmDirName.Length - bsIndex);
string dllpath = asmDirName + "\\" + assemblyname;
Regasm("/codebase", dllpath);
}
}

public override void Uninstall(IDictionary savedState)
{
string assemblyname = Context.Parameters["ASSEMBLY"];
if (assemblyname != null)
{
Assembly asm = Assembly.GetExecutingAssembly();
string asmName = asm.Location;
int bsIndex = asmName.LastIndexOf("\\");
string asmDirName = asmName.Remove(bsIndex, asmName.Length - bsIndex);
bsIndex = asmDirName.LastIndexOf("\\");
asmDirName = asmDirName.Remove(bsIndex, asmDirName.Length - bsIndex);
string dllpath = asmDirName + "\\" + assemblyname;
Regasm("/u", dllpath);
}
base.Uninstall(savedState);
}

private void Regasm(string parameters, string dllPath)
{
string regasmPath = Path.Combine(RuntimeEnvironment.GetRuntimeDirectory(), "regasm.exe");
if (!File.Exists(regasmPath)) throw new InstallException("Registering assembly (" + dllPath + ") failed");
if (!File.Exists(dllPath)) throw new InstallException("Registering assembly (" + dllPath + ") failed");

Process process = new Process();
process.StartInfo.CreateNoWindow = true;
process.StartInfo.UseShellExecute = false; // Hides console window
process.StartInfo.FileName = regasmPath;
process.StartInfo.Arguments = string.Format("\"{0}\" {1} /tlb", dllPath, parameters);
process.Start();
process.WaitForExit();
}
}

Anyway, I put this here so that it might help someone else. However, most of such things I put on Stack Overflow under my name.

Sunday, March 29, 2009

"A different way to think about creative genius"

This weekend we went to a restaurant in Reykjavik with some friends we haven't seen for quite some time. During dinner when we were talking my friend mentioned that he had been reading a book on genius. It was a very interesting discussion, which reminded me of a TED talk by the author Elizabeth Gilbert.

It's a good talk about how a person should not be considered a genius but a genius should be considered an entity of its own that visits perseptive people and enhances their abilities. This is in contrast to the way genius is usually described, for example Wikipedia describes a genius as an individual:

A genius is an individual who successfully applies a previously unknown technique in the production of a work of art, science or calculation, or who masters and personalizes a known technique.

Elizabeth's talk is called A different way to think about creative genius. Take a look at her talk at TED and by the way there are many other great talks there that might interest you.

Wednesday, March 4, 2009

Are you demoralized?

Joel Spolsky did an article in Inc. this month that you should read if you have ever done a start-up or you are thinking of doing a start-up or you would like to do a start-up. Take a look at How Hard Could It Be?: Start-up Static




From the article:

When she asked me what she should speak about, I asked her to consider describing all the different ways a start-up can fail, rather than the usual stuff about lessons learned from people who succeeded.

"That would be boring," she told me. "They all fail for the same reason: People just stop working on their business." Um, yeah, well, sure, and most people die because their heart stops beating. But somehow dying in different ways is still interesting enough to support 40 hours a week of prime-time programming.

But the more I thought about it, the more I realized Jessica was onto something. Why do start-ups fail? As she pointed out, it's usually a collapse of motivation -- everyone wanders back to civilian life, and the start-up ends, not with a bang but a whimper.

Paul Graham, Jessica's husband and partner in Y Combinator, has tackled this subject on his website. "The biggest reason founders stop working on their start-ups is that they get demoralized," he writes. "Some people seem to have unlimited self-generated morale. These almost always succeed. At the other extreme, there are people who seem to have no ability to do this; they need a boss to motivate them. In the middle there is a large band of people who have some, but not unlimited, ability to motivate themselves. These can succeed through careful morale management (and some luck)".

What cought my attention was the quote from Paul Grahams website.

Now, go read the article!

David Platt in Iceland 2009!

In the end of august last year I wrote about David Platt on WCF in Iceland! where I was very enthusiastic about David Platt coming to Iceland in the middle of October. But then he didn't, in the beginning of October I got the news that his course was canceled. In Cancellation, cancellation and cancellation I guessed it was because of the financial crises in Iceland but I had no idea. I still don't have any idea why it was canceled. Then, in the beginning of this year I got an email saying he was going to be in Iceland in the beginning of February and this time there was no cancellation.

The 4th of February I went to the university to watch him do three talks from early morning until late afternoon:

Why Software Sucks - follow-up to his book
WPF for Good and not for Evil - same as in Tech-ed 2008
Know Thy User: Instrumenting The User Experience

BTW: The image at the top is NOT from the Iceland talks.

I knew quite a few in the audience but I sure was missing a lot of my developer friends, the audience was more of the type of designers and testers than developers and geeks. I think developers sure would benefit from watching. But when David Platt mentioned that he had been in Iceland 9-10 times over the last decade or two I thought maybe my developer collegues had already seen the talks.

His style is funny and fresh, and the message is also very informative and important. His view of usability is right on the money and his simple message "Know Thy User, For He Is Not Thee" is easy enough to understand and remember. He talks about software needing to become much simpler to use and makes examples of such software, which is very simple and extremely useful to the user. He says developers need to understand that nobody wants to use software, people want to have used software.

One of the things he talks about that will make software simpler to use is if fewer clicks are needed to get things done. Each click would in the end cost the customer a lot of time and money. Interesting. When he was talking about this I remembered a story I heard close to 20 years ago from Apple. Some developers had been assigned to decreasing the Apple computer startup time. The developers didn't understand what it would help to decrease the startup time by a second or two, nobody would notice. The story goes that Steve Jobs told them to try multiplying the two seconds with the number of Apple computers they had sold, which would be restarted a couple of times per month, and see how much time they would be saving the users every single month. By looking at this time as money, they were actually saving a lot of money by decreasing the startup time by even just a second or two. Interesting. I don't think a lot of people see it like that.

Anyways, the talks are good. If you haven't seen David Platt already then find a way when he is available in your country. You will enjoy it. At least I will be keeping my eyes open for his WCF course I missed last year.

Thank you David Platt.