I am writing a wrapper around two different versions of a communication library that work with different versions of my company's database. These communication libraries have classes with identical fully-qualified names, so I am loading the references into different aliases; I've tried it with one or the other in the global alias and with both in non-global aliases, and in both cases Visual Studio 2012 complains that I have compile errors. In specific, in both of my wrapper classes, I am fetching a connection from a factory method
extern alias MyAliasVersionX;
using MyAliasVersionX::Example.MyNamespace;
...
private Connection _connection;
...
_connection = Connection.Create(environmentName); // this returns an Example.MyNamespace.Connection--but this is where the compile error happens
The code is virtually identical in both classes; the biggest difference is the version on the alias in the using statement at the top. In one class (it appears to be whichever reference is listed first), everything works fine, no error. In the other class, Visual Studio tells me that the line noted above will produce a compile error because Connection.Create() returns the other version of Connection object (i.e., MyAliasVersionY::Example.MyNamespace.Connection instead of MyAliasVersionX::Example.MyNamespace.Connection).
Here's the important part: when I actually Build the project, it compiles fine and runs fine, and the error showing in the Error List pane disappears... until I make any change to the code, at which point it comes back, still never causing a Build error.
Is this a bug in Visual Studio? If not, what am I missing?