Visual Studio shows error CS0029 for types in non-global alias

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?

Answers


This is a bug in Visual Studio dating back to VS-2008, according to Microsoft. It won't likely be fixed until a major overhaul of VB.NET/C# editing (called "Roslyn") is released. (If you're dissatisfied with that, upvote my Connect feedback below to let Microsoft know!)

https://connect.microsoft.com/VisualStudio/feedback/details/786107/visual-studio-shows-error-cs0029-for-types-in-non-global-alias


Need Your Help

Javascript / jQuery to Servlet communication

java jquery ajax java-ee

I was searching for this earlier and was little confused by the answer i got around so i felt like writing a complete code for this. This is for my future work and i hope someone get benefited by t...

Syntax highlighting with attributed strings on UITextView

ios uitextview syntax-highlighting nsattributedstring

There is an excellent project to add syntax highlighting and line numbers to your project: https://github.com/illyabusigin/CYRTextView

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.