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.
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.
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.
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).
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.
Navigate back to the code file in which the problem is occurring. Above all the usings, add
And change the using to
The build succeeds. For the curious, yes the global:: is implied but can be made explicit…
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.
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.
This post originally appeared on The DevStop.