Compiling in VS2010 target .NET 4.0 has minor problem

Aug 1, 2009 at 9:16 PM

I decided to see if Unity 1.2 would work in VS 2010 Beta 1 against .NET 4.0 since I am playing with Azure.  I am not too excited yet about Unity but am trying to get up to speed so all I was concerned with was would it compile successfully.  The short answer is no.

BUT - I got it to compile successfully with very little effort.  I have no idea if it even matters that was not the point.

Since I never had VS2005 loaded on this machine.  I first opened it in VS2008 and it had a bunch of problems with broken references (Microsoft.VisualStudio.QualityTools.UnitTestFramework) after the conversion.  I fixed the references and it compiled ok.  I then went through and changed the target from .NET 2.0 to .NET 3.5 sp1 and it all worked fine.  Also since I have Enterprise Library 4.1 on this machine I targeted it and it still had no problems compiling.

I next made a copy of the project and opened it in VS2010 and it had no problems in the conversion.  However it would not compile.  I did not investigate to see what the differences might be in the default setting between VS2008 and 2010 but the problem was an ambiguous reference in the project TestSupport.Unity.  This project contains a class call "Barrier" in Barrier.cs and has a reference to System.Threading.  Using the ObjectBrowser I could see that System.Threading also defines "Barrier" which is NOT abstract.  I double checked and the project's version was not inheriting from any other class or interface.

The conflict was occuring in project Tests.Unity filename PerThreadLifetimeManagerFixture.cs

My solution was very simple, since the Barrier class was a local project class I simply changed its name from "Barrier" that duplicated the System.Threading.Barrier class to "_Barrier".  I did a quick fix-up of the offending references and all was well.  I for kicks went through and targeted all the projects to .NET 4.0 and still had no issues.

All of you who use Unity may take all kinds of issues with this... I don't care. I don't yet use Unity in any project; I am just playing around on a very rainy Saturday afternoon trying to learn a new trick or two.


Aug 2, 2009 at 3:12 AM

Larry, thanks for the experience report. Glad to know it was fairly easy.

For what it's worth, the intended use of our Barrier class and the one in the CLR is the same, so it's probably a good idea if we make sure our version has the same interface as the one in .NET 4.0. That way, the solution there is just to delete the class.

The broken references with the Unit test assembly is something we've known about for a while; unfortunately the upgrade wizard doesn't upgrade MSTest unit test projects correctly. Oh well.