# Friday, May 05, 2006

Say you have an application that uses P/Invoke (the DllImport attribute on an external method defined in a native DLL) to access some particular functionality. A lot of the use for this feature is to get to something in the Windows API that isn't exposed by the .NET Framework. But there are also folks using P/Invoke to call their own code from their own DLLs. The question then arises: where should you keep that DLL you're using (oh, please, not System32, anywhere but System32 -- years ago a buddy said "the registry is a giant and complicated database that tells you all your COM objects and DLLs are in System32") and how is it going to get deployed from your computer to wherever you install it?

If you try to add a random file to your manifest on the Publish tab of a Visual Studio 2005 Winforms project, you will discover there really isn't a way to do it. The file has to be in the project. You can add things to your manifest with MaGeUI (Manifest Generator with a User Interface, so named because MaGe is entirely command-line) which you can run from a Visual Studio command prompt, but most of us want to manage our manifests with Visual Studio. Heck, you could edit your manifest with Notepad -- it's only XML -- but that's not what I'd call the popular choice.

You could add the DLL to your project, but if it's under development, you're going to have to hand-update your copy when it changes, or your tests won't be accurate. And for a lot of folks, adding it to the project is going to mean adding it to source control, and binaries in source control does not sit well with me. Here's a better way.

Start as though you were going to add the DLL to the project. Right-click the project in solution explorer, Add, Add Existing Item, browse to where the DLL is, change the file type to All Files or Executables, click the file name - but don't click the Add button. It's a compound button, so click the little Arrow next to Add and choose Add As Link.

You should see your file added to Solution Explorer with a sort of shortcut symbol:

Click once on the DLL then bring up the properties for the file. Make sure Build Action is set to Content and Copy To Output Directory is set to Copy If Newer. (If the DLL is on the network, and you're working offline, on a plane or something, and you've built once so you have a copy already, you can flip this setting back to Do Not Copy so your builds don't fail.)

A word about "where the DLL is". If you develop alone, this can be some sort of c:\working\clientname\projectname idea, but for a team, that's not going to work. This path is going into your project file and you'll check it in to source control and the rest of the team will be using it. Unless you all have the same folder structure, you're going to want to use a UNC name. It's probably best to point it at a share where you publish the DLL after you build it.

Having added the file to the project, you can now make it part of what you publish. Click Application Files on the Publish tab and you should see it there. You might need to check the Show All Files box, but I didn't:

This isn't available in every kind of project -- I can't do it in a C++ WinForms app, for example -- and it doesn't really work for an ASP.NET app where there is no project file, just the folder. I think for those a pre- or post build step to copy the DLL from where you build it or from the share where it is published for all developers to use would be the way to go.

Kate

Friday, May 05, 2006 7:38:03 AM (Eastern Daylight Time, UTC-04:00)  #    
# Tuesday, May 02, 2006

I installed Vista build 5365 last week. This was just a short time after putting 5308 on bare metal instead of a VPC. And now instead of just "checking it out" and "looking around" I was actually using the OS to do work, specifically writing code. (I was doing Word and Powerpoint work on my other laptop which is still on XP.) There's an interesting emotional thing that happens when you get out of the VPC and onto the metal, and especially when you stop demoing and start doing.

There are some things here I am just loving, somewhat to my surprise.

How long have I been annoyed by having to retype the extension when i rename a file? A decade at least. This is a tiny thing but ooo-weee I like it.

The easiest way to tell what I love is when I try to do it on my other machine and feel a momentary irritation when I can't:

This is a Windows Explorer and the address bar is all buttony and live. So I don't have to click up three times, wait while lists of things I don't care about update, and then drill back to where I want. I keep trying to do this on XP, I have it completely internalized already.

Like Scott Hanselman, I have a LOT in my Start menu. I like this in-place effect a WHOLE lot better than the cascading-off-to-the-side-forever approach.

One thing I was hating: where is Start, Run? I can't live without Start, Run! Turns out Windows-R still works. So does right-clicking on Computer and choosing Manage to get all the MMC stuff you need to admin your box.

Speaking of adminning your box, the User Account Control takes a bit of getting used to. More than once I have had to close Visual Studio and re-open it as admin so the COM component can get registered as part of the build process. But I am developing some habits there and expect to internalize those quickly too. I have a feeling we will all be on Vista sooner rather than later.

Kate

ps: don't draw conclusions about visuals from these shots, I don't have Glass on the laptop (it's an old one) and I don't have anything for screenshots other than Shift-PrtScr then paste into Word. It's nicer in person, really.

Tuesday, May 02, 2006 3:58:55 PM (Eastern Daylight Time, UTC-04:00)  #    
# Monday, May 01, 2006

Martyn Lovell, who heads the libraries team, has an interview on Channel 9 that was posted Friday. Normally when you think "libraries" in the context of C++ you think ATL and MFC. But most of what Martyn is talking about here is the C RunTime library -- strcopy, printf and so on. He gives a coherent explanation of what the safer CRT work is about. I've written about this before, and have been helping mentoring clients fix their warnings for over a year, and still I learned a few things from this video about how to explain this initiative. Martyn's devotion to the language and the community is inspiring.

And yes, Martyn is hiring again. You can use the description and instructions from my previous post if you'd like to work on MFC. Over 7000 new APIs in Vista means there's lots of MFC work to be done!

Kate

Monday, May 01, 2006 8:33:41 AM (Eastern Daylight Time, UTC-04:00)  #    
# Friday, April 28, 2006

Last night we had a community get together on the last day of VSLive. Billy Hollis, Steve Lasker, and Josh Holmes were there from out of town, and the Toronto .NET Glitterati (Rob Windsor, Graham Marko, Chris Dufour, Jean Luc David, Dave Totzke, Barry Gervin, Eli Robillard, and many others) as well. It seems that no-one had a camera along, so you'll have to take my word for it :-).

I got a chance to talk to Jerome Carron, who like me is speaking as part of the realDEVELOPMENT_06 tour in late May and early June. We will be seeing a lot of each other since we are also both going to be at DevTeach. If you haven't registered for either of these events, you really should.

I've been quiet lately because I've been preparing my slides for DevTeach and TechEd, and working on some material for a Vista Ascend that premieres in May. I also put a new Sharepoint site into production at a client -- and if you've ever had the delight of promoting a gaggle of web parts, aspx pages, and special versions of selected magical XML files all up to a production server from a staging server, then you know why I haven't had time to blog. But it works now, and the clients are all happy. Me? It's a good thing I know how to sleep on a plane.

Kate

Friday, April 28, 2006 3:12:30 PM (Eastern Daylight Time, UTC-04:00)  #    
# Thursday, April 27, 2006

The other day, my car overheated -- pegged the temperature gauge -- after about 5 minutes of driving. I limped it home and discovered it was out of engine coolant. After I added more I could drive for a few minutes but again it violently overheated and all the coolant was gone. With visions of expensive repairs dancing in my head I took it to my neighbourhood mechanic.

It turned out to be a cheaper repair than I expected, but a more frustrating one. You see, the minivan I was driving has a separate heating system for the back seats. Their own controls, vents, everything. We actually use this perhaps once a year, it's a low-value frill. But here's how it works: they pipe the engine coolant halfway back the car so it can go through a heat exchanger and warm up the air in the back. And of course it makes cars easier to build if all the pipes and wires are underneath the car. Over the years, kicked up stones and gravel weakened this coolant pipe until it finally broke, spewing precious engine coolant all over the road. I could have easily lost the engine or been stranded hundreds of miles from home. And for what? A separate heating system in the back? Who cares?

What could they have done instead? They could have piped the hot air instead of the hot coolant, so a leak would only make the back seat cold instead of ruining the car. (I know, from my former life as a chemical engineer, how much easier and cheaper it is to move liquid than air.) They could have installed a sensor that would detect low coolant levels directly, instead of indirectly when the car overheats. They could have run the piping in some protective shroud. (Ha! This is the company that blames me when the wiper motor breaks because the car gets snow and ice on the windshield! Three times so far on this van.) They could have skipped the whole feature on the grounds it made the car way too vulnerable for the benefit it offered.

I see a moral in this story for software developers. What features are you writing that turn out to be a heating system for the back of the van?

Kate

Thursday, April 27, 2006 8:09:49 AM (Eastern Daylight Time, UTC-04:00)  #    
# Friday, April 21, 2006

I've just updated the mentoring and consulting pages on our website. The mentoring offering is where I get most of my fun, so we've decided to emphasize it a little more. I even found out how to put flare on my blog. Tell your friends :-)

Kate

Friday, April 21, 2006 10:52:35 PM (Eastern Daylight Time, UTC-04:00)  #    
# Thursday, April 20, 2006

I just spent a TON of time fighting an XSLT stylesheet. This is a long established system that needed a tiny change -- the customer wanted the little R-in-a-circle symbol after one of their trademarks. No problem, right? Go on into the XSLT and put ® in the appropriate place. Not an entity known to XSLT. Right, I remember that. But heh heh you can't stop me: ® should do it. Test in XML Spy and there's the symbol. Generate and upload all the pages and -- yikes! -- everything says ? where it should say ®! I don't think my clients want the header on every web page to say REALTOR? -- a little certainty is wanted here. That's because XSLT is putting the actual symbol into the HTML -- if you do a View Source on the web page there's no entity, there's the actual symbol and some browsers can show it and some can't. OK, let's try ® or ® -- they come out looking just like that on the screen. Bleah. More Googling. Suggestions to define DOCTYPES and ENTITYs that all manage to stick the symbol into the HTML but not the entity. A brief attempt at some circular definitions of reg to reg, some desparate CDATA flailing -- and then we got it:

Literal text in the middle of the XSL stylesheet:

REALTOR<xsl:text disable-output-escaping="yes">&amp;</xsl:text>reg;

We have a winner. I get &reg; in the HTML and my client gets their trademark.

Kate

Thursday, April 20, 2006 6:51:50 PM (Eastern Daylight Time, UTC-04:00)  #    
# Thursday, March 23, 2006

It looks like I never added an entry about speaking at Devteach. I just made my travel plans to get there. I love taking the train to Montreal -- I'll end up within walking distance of the conference hotel, save time compared to flying, and travel in comfort the whole way.

Devteach is a delightful conference with a friendly atmosphere. I count 8 RDs among the speakers list, plus a whole pile of MVPs, Julie, and some of my favourite Microsoft people... DEs mostly. There is one track in French and the rest of the talks (about a hundred) are all in English.

My talks are:

  • Moving C++ applications to the CLR
  • The Future is Concurrent

There's plenty for everyone: web, smart client, data, security, patterns and practices, testing, Team Systems, architecture -- if it's a development topic, someone is speaking on it. On top of that the conference hosts the Canadian User Group Leader Summit (and gives user group members a discount on attendance - contact your user group leader for a code) and the Canadian Regional Director Summit. It's a great place to meet the stars of the Canadian developer community, and a number of folks from the American northeast who love to come up to Montreal. See you there!

Kate

Thursday, March 23, 2006 7:25:00 AM (Eastern Standard Time, UTC-05:00)  #