Some days ago I was doing some tests with Visual Studio 2008 Beta 2 and I saw the DbType enumeration contains two new members, DateTime2 and DateTimeOffset, until here nothing strange.
The problem came up today when I was working with Visual Studio 2005, I was using again the enumeration and I saw the Intellisense also shows these new members, which are not included with the Framework 2.0.
This is very weird but the first thing I thought was that it could be a problem with the Intellisense being corrupted after install Beta 2. So, I wrote some code making use of them. The code is very simple, I display in a console application the string and the int representation of “DateTime2”. Then I convert the string and int representation of “DateTime2” to the equivalent enumerated object.
This works perfectly without any error from Framework 2.0. The compiler and the references used from VS2005 are got from the path “Framework\v2.0.50727\”, so all seems to run as expected, but this is very confusing because these are new values added in the Framework 3.5 and work from Framework 2.0
In fact, if you try to build the same application from a computer without the Visual Studio 2008 beta 2 installed, you cannot compile it. The thing is that you can even run it and all works smoothly, except when you try to parse into a variable of DbType the string representation, this will throw an exception because of course “DateTime2” is not a valid name value of the DbType Enumeration.
If we look more in deep what can cause this, we will see that the files csc.exe and the System.Data.dll have different file versions on computers with VS 2008 Beta 2 installed. You can even use reflector and decompile the System.Data.dll to see that the enumeration contains the new values.
This is very upsetting because introducing this simple code can make your application crashes during runtime, note that we were using Visual Studio 2005 to build and run the code and all works fine until you move it to another computer without VS2008 installed.
This is clearly not side-by-side execution and I hope it is just a bug that will be fixed or something I overlooked, otherwise I can see lot of bad times when half of the park works with Visual Studio 2008 multi targeting and the other half with Visual Studio 2005.