What rules govern cross-version compatibility for .NET applications and the C# language?
Posted
by John Feminella
on Stack Overflow
See other posts from Stack Overflow
or by John Feminella
Published on 2010-02-25T13:01:17Z
Indexed on
2010/05/08
23:28 UTC
Read the original article
Hit count: 175
For some reason I've always had trouble remembering the backwards/forwards compatibility guarantees made by the framework, so I'd like to put that to bed forever.
Suppose I have two assemblies, A
and B
. A
is older and references .NET 2.0 assemblies; B
references .NET 3.5 assemblies. I have the source for A
and B
, Ax
and Bx
, respectively; they are written in C# at the 2.0 and 3.0 language levels. (That is, Ax
uses no features that were introduced later than C# 2.0; likewise Bx
uses no features that were introduced later than 3.0.)
I have two environments, C
and D
. C
has the .NET 2.0 framework installed; D
has the .NET 3.5 framework installed.
Now, which of the following can/can't I do?
Running:
- run
A
onC
? runA
onD
? - run
B
onC
? runC
onD
?
Compiling:
- compile
Ax
onC
? compileAx
onD
? - compile
Bx
onC
? compileBx
onD
?
Rewriting:
- rewrite
Ax
to use features from the C# 3 language level, and compile it onD
, while having it still work onC
? - rewrite
Bx
to use features from the C# 4 language level on another environmentE
that has .NET 4, while having it still work onD
?'
Referencing from another assembly:
- reference
B
fromA
and have a client app onC
use it? - reference
B
fromA
and have a client app onD
use it? - reference
A
fromB
and have a client app onC
use it? - reference
A
fromB
and have a client app onD
use it?
More importantly, what rules govern the truth or falsity of these hypothetical scenarios?
© Stack Overflow or respective owner