Question

I'm looking for a solid advice on forward compatibility between specific versions of .NET framework.

For clarity, let's suppose we're talking about SQL Server 2008 which only supports .NET 2.0, and into which we load a v3.5 assembly with a stored procedure, plus all its v3.5 dependencies.

How do these fact combine?
Is the "CLR is same" fact to win? Can we say that, since CLR version is the same between the three FW versions, v3.5 code can be safely introduced into v2.0 environment, provided all its dependencies are also introduced? In which case can we dismiss the "forward compatibilty not supported" notice as being true in general case, but not true in the particular case of v3.5-v2.0 relationships?

(We have actually tried importing a v3.5 assembly with all dependencies into SQL Server 2008. It works. But I want to know whether it works because it should, or because of a fragile magic.)

Was it helpful?

Solution

There is no such thing as a ".NET 3.5 assembly". The only version imprinted on an assembly is the runtime version it requires. Which is v2.0.50727 for any assembly built by a compiler included with .NET versions 2.0 through 3.5 SP1. With the further twist that this really specifies the format of the metadata in the assembly. Only CLR version 2 or greater can read the manifest in the assembly. This format changed in 4.0, the core reason you need CLR version 4 to execute an assembly that targets 4.

The only distinction between framework versions 2.0 through 3.5 SP1 is in the set of assemblies that are included. You can only add an assembly reference to, say, the WPF PresentationFramework assembly when you target 3.0 or greater. You can only add System.Core when you target 3.5.

Avoiding these new assemblies in a SQL project is not difficult. You'll get a swift exception if you get it wrong.

OTHER TIPS

I think your very first assumption that "SQL Server 2008 only supports .NET 2" is wrong, so all the following discussion will be meaningless.

If you take a look at this article, you can see that .NET 3.5 is supported, as System.Core is .NET 3.5 only,

http://msdn.microsoft.com/en-us/library/ms403279(v=sql.100).aspx

Now you can confidently use your .NET 3.5 assembly.

SQL Server loads the 2.0 CLR, which is compatible with 3.x. So, yes, "the CLR version is the same" wins.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top