Unable to build SQL CLR project targeted for .NET 3.5 in Visual Studio 11
-
Friday, April 13, 2012 8:39 AM
I am trying to build a .NET 3.5 SQL CLR database project for SQL Server 2008 R2 using Visual Studio 11 Beta. It looks like there is a bug where it is compiling with 2.0 instead of 3.5. I want to use System.TimeZoneInfo which is only in 3.5. When I compile for 4.0 it compiles using appropriate references (though 4.0 is not supported on SQL 2008).
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Csc.exe /noconfig /nowarn:1701,1702,2008 /nostdlib+ /errorreport:prompt /warn:4 /define:DEBUG;TRACE /errorendlocation /highentropyva- /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\mscorlib.dll /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Data.dll /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.dll /reference:C:\Windows\Microsoft.NET\Framework\v2.0.50727\System.Xml.dll /debug+ /debug:full /optimize- /out:obj\Debug\MyAppSqlClr.dll /target:library /warnaserror- /utf8output DateTime.cs "C:\Users\anon\AppData\Local\Temp\1\.NETFramework,Version=v3.5.SqlClrAttributes.cs"
I have installed 3.5 on my Windows Server 2008 R2 dev machine via Control Panael => Add Features, though not all of the libraries appear in C:\Windows\Microsoft.Net\Framework\v3.5... as one might expect.
All Replies
-
Monday, April 16, 2012 7:13 AMModerator
Hello Partner,
As far as I know that SQL Server 2008 R2 requires these SQL CLR assemblies target version 2.0, 3.0, or 3.5 of the .NET Framework, so it is correct for you to target the SQL CLR project to .NET 3.5 in VS11 Beta.
As we know that the .NET Framework 2.0, 3.0, 3.5 actually uses CLR 2.0 to build projects, and there are no modifications of these core asseblies (for example, mscorlib.dll, System.dll and System.Xml.dll) in CLR 2.0, so your compiler uses these assemblies in the v2.0.50727 folder. In addition as you have installed VS11 Beta, when you build your project, you actually use the v4.0 compiler. In other words, there is no relationship between the version of the compiler you are using and the version you target in the project. So I think the output you get in the VS is correct.
Thanks.
Vicky Song [MSFT]
MSDN Community Support | Feedback to us
-
Monday, April 16, 2012 5:46 PM
Thank you, Vicky. Since TimeZoneInfo is in mscorlib.dll in 3.5, does that mean that it is not available, or is there a way to specify the newer mscorlib.dll? I've also opened the following issue on Connect.
- Marked As Answer by Vicky SongModerator Thursday, April 26, 2012 3:34 AM
-
Tuesday, April 17, 2012 7:42 AMModerator
Hello Anonymous,
As I mentioned above, .NET Framework 2.0, 3.0 and 3.5 all use CLR 2.0; .NET Framework 4.0 and 4.5 use CLR 4.0. So if you target your project framework to be 3.5, you actually use the mscorlib.dll in the v2.0.50727 folder. In addition, if you take a look at the folder C:\Windows\Microsoft.NET\Framework\v3.0 or C:\Windows\Microsoft.NET\Framework\v3.5, you can't find the mscorlib.dll.
And if you target your .NET Framework to be 4.0 or 4.5, you actually use the mscorlib.dll in the v4.0.30319 folder.
Thanks.
Vicky Song [MSFT]
MSDN Community Support | Feedback to us

