If the target framework 3.5 then you are using C# 2.0 with extensions. ArcEngine 10 needs to target .NET 3.5 so you miss out on some 4.0 goodies. I wanted to use a wpf calendar control in my app, but I couldn't because that's 4.0. So I had to use the winforms one.
–
patrickFeb 28 '12 at 15:32

I was using C# 4.0 to develop an extension for ArcMap 10 with the target framework set to 3.5 so I was wondering if it would be backwards compatible as long as the framework stayed 3.5. Should I change my ArcMap 10 extension to C# 2.0 so it can be recompiled with ArcMap 9 without having to make many code edits? Will C# 3.0 work with ArcMap 9?
–
Mike RogersFeb 28 '12 at 15:58

2 Answers
2

Short answer: In my experience, there should be absolutely no problem developing .NET 3.5-based code for ArcGIS 9.3 in Visual Studio 2010 (with C# language version 4), as long as you explicitly target the .NET Framework 3.5. The C# language version is mostly irrelevant here.

P.S.: This answer does not go into the differences that exist between developing an ArcGIS extension for versions 9.3 and 10. (ESRI has made quite a few major changes to the add-in model, but I'm assuming you're aware of that.)

Longer answer: You need to distinguish between the C# language version, and the targeted Framework version.

You can think of the .NET Framework as being made up of two major parts: the CLR (Common Language Runtime), and the BCL (Base Class Library). The former is the "virtual machine", while the latter is the class library (containing all the types that you can look up on MSDN).

.NET Frameworks 2 until 3.5 all use the same CLR (version 2), that is, the execution environment hasn't really evolved. What has evolved, however, is the BCL. If you're running a .NET 3.5 application on a .NET 2 machine, the main problem will not be that the "bytecode" (CIL) will be incompatible (it won't), but that the application might refer to and use types that were not yet available in the .NET 2 BCL.

Now, when you tell Visual Studio 2010 to target the .NET Framework 3.5, it will make sure that you won't use BCL types from any later Framework version. It will also make sure that the code output by the C# compiler will not require features only available in the CLR version 4.

The C# language version has very little to do with all this. What the C# compiler really does it to take your source code and translate it to a much lower-level programming language called CIL (Common Intermediate Language). Certain C# language constructs will no longer be recognisable in CIL: For example, yield return and yield break do not exist in CIL. They are simply translated to implementations the IEnumerator<T> interface.

To sum this up: The C# language version becomes irrelevant as soon as your code is compiled. What is important is...

whether the output CIL/"bytecode" is compatible with the targeted .NET Framework (if you target .NET 3.5, it will be compatible even with .NET 2 for the reasons mentioned above); and

whether your code refers to / makes use of types that are available in the target framework.

One notable exception (in the sense that a C# language construct requires a particular version of the framework; this was last the case whwn generics were introduced IIRC) might be the C# keyword dynamic. It might be compiled to code that requires types from the System.Dynamic namespace, which is only available since .NET 4. But don't worry: If you've set up your Visual Studio 2010 project to target the .NET 3.5, you should get a compiler error if you're trying to use stuff that is not available, or compatible with, that particular .NET Framework version.

Thank you for the detailed explanation!
–
Mike RogersFeb 28 '12 at 17:57

1

@SeaJunk, this is not fully correct. Even if there might be no ESRI SDK extension for ArcGIS 9.3/VS2010, this won't stop you from referencing ArcGIS assemblies and start writing code. That is, it's still possible to use that IDE, only more uncomfortable. There might also be some more manual work involved (registering components etc.) but again, it's feasible AFAIK.
–
stakxFeb 28 '12 at 18:20