The Many Adventures of Externalias

The bad news is, I’m not much of an artist.

The good news is, if I draw this in Paint .NET, it’s about the same as if I draw it on the whiteboard and take a picture.

image

His name is Externalias. He has been described as “a kind of Pac-Man thingy, but with one wing on his back, and antenna…and a lot more scary.” His nemesis is Subtopdecor, but that’s for another post. You may ask yourself, “Why is Ruttka sharing this?” I write to you today about Externalias because his origin story contains a useful answer, and despite the silliness (horror?) of the mascot, it’s possible someone could benefit from hearing it.

About two years ago, my friend Chris sat looking at red squiggly. It implied that he was not referencing a required assembly or was missing a using statement. He was definitely referencing it. We found that the using statement also griped that the namespace didn’t even exist. As he manually typed the using statement from scratch, intellisense never showed the namespace that he needed to use for the desired type.

I didn’t know the answer at the time, but when it happened again last week, I recognized it and was able to fix it pretty quickly.

Fast-forward to the present. Here is one way to get into a very similar situation for which the resolution is identical, but overly simplified and contrived for the purposes of illustration in a blog post. Click any of these images to embiggen.

image

I will not be going into how or why such a situation is ever created. What I will say that I’ve seen it on multiple projects with multiple teams in multiple organizations, so it undoubtedly does happen.

When you build, or rather when you try to build, it’s not going to work.

image

The type ‘Foo.Data.Bar’ exists in both ‘c:\src\Externalias\Foo.Data\bin\Debug\Foo.Data.dll’ and ‘c:\src\Externalias\Foo\bin\Debug\Foo.dll’

The error message describes the problem fairly well, but unlike other errors, it doesn’t recommend a solution.

Now, back to that day a few years ago, when I popped into my friend’s cube a little later, he had just found the answer: EXTERNALIAS! Of course, he had said extern alias, but I was in the habit of hearing words mashed together (see also: Subtopdecor).

image

Here’s what you have to do. View the references of the project in which the problem is occurring, and choose one of the colliding assembles (doesn’t really matter which). View the Properties for that reference, and note that it (like all the others, most likely) is only in the “global” alias. Add another, comma separated.

image

Navigate back to the code file in which the problem is occurring. Above all the usings, add

extern alias {theAliasYouJustMadeUp};

And change the using to

using {theAliasYouJustMadeUp}::{whatYouReallyReallyWant}

image

The build succeeds. For the curious, yes the global:: is implied but can be made explicit…

image

Acknowledgments

Thanks, Chris, for being the first person I know to have encountered this. May you never encounter it again.

Thanks, Externalias, for being the greatest doodle I’ve ever created and preserving the memory of this solution in such a whimsical form. May your presence on developer whiteboards be ever increasing.

Update

What I left out is that (long story short) I doodled these characters on our whiteboards. If I remember correctly, Subtopdecor came first. After I misheard “Subtopdecor,” Chris said it sounded like the name of an evil robot. My first sketch of Subtopdecor was somewhat leaner and meaner, but along the way he filled out and got a little more neutral. I prefer the original interpretation, but for some reason I can no longer draw it successfully. For Externalias, the doodle came first, quite randomly. It was only later that I misheard “Externalias” and we applied the name. They have been spotted at venues as grand as the McWane Science Center in Birmingham.

Advertisements

About David Ruttka

I've been "making computers do things" since I first saw King's Quest on a 286 PC in the mid-80's, but I turned it into a career just over a decade ago. While the majority of my experience has been on the Microsoft stack (C#, .NET, ASP.NET), I've recently been diving deeper into JavaScript and exploring the Ruby universe. Occasionally, I'll do a public speaking gig or write a blog post. When I'm not coding, I enjoy spending time with my family, watching hockey, and playing the occasional video game. You can also find me on Stack Overflow, Google Plus, and Twitter. Microsoft Certified Programming in HTML5 with JavaScript and CSS3 Specialist; MCPD Windows Developer 3.5
This entry was posted in Development, Stories and tagged , , . Bookmark the permalink.

Thoughts?

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s