.NET 4.0 and 4.5 support for ArcGIS 10.2 Desktop and Engine developers


Summary
This topic contains information about using the .NET 4.0 and 4.5 Framework when developing ArcGIS 10.2 Desktop and Engine applications.


Using .NET 4.0 and 4.5 at ArcGIS 10.2

If you require any of the .NET 4.0 and 4.5 Framework functionality, you can extend Esri products with components written in the .NET 4.x Framework. However, it's your responsibility to redistribute and/or verify that the .NET 4.x Framework exists on the target system.
To start debugging a .NET 4.x add-in or custom component within an ArcGIS for Desktop application (that is, ArcMap, ArcCatalog, and so on), the developer must modify the specific application's configuration file on their developer machine to add support for the .NET 4.x runtime, or they can attach to the process through Visual Studio.
For example, if a developer builds a .NET 4.x add-in for ArcMap, to start debugging, the developer must edit the ArcMap.exe.config file located in the ArcGIS Desktop bin folder.  This configuration specifies the common language runtimes that are supported within the application, and redirects assemblies to allow older components to be tested in the current version of ArcGIS. Within the application configuration file, you should see the following code:         
[XML]
<startup>
  <!--<supportedRuntime version="v4.0.30319"/>-->
  <supportedRuntime version="v2.0.50727"/>
</startup>
To enable debugging from the start debugging command in Visual Studio uncomment the .NET 4.x <supportedRuntime> element.
Since desktop .NET add-ins do not require a setup to deploy and can be installed by double-clicking the add-in or by using the Add-in Manager, there is no way to verify that a client has the .NET 4.x Framework before installation. Consequently, if you target the .NET 4.x Framework, you are potentially limiting the number of users who can consume your add-in.
The best practice is to target the .NET 3.5 Framework with your solutions, since .NET 3.5 SP1 is a requirement for ArcGIS for Desktop and ArcGIS Engine for Windows. Targeting the .NET 3.5 Framework runs without any additional work other than verifying that the appropriate product is installed on the client machine.

Impact of creating .NET 4.0 and 4.5 solutions with assemblies built using the .NET 3.5 Framework

Previous versions of the .NET framework can be installed side-by-side, but only one version of the framework can be loaded into a process. This caused potential compatibility issues with solutions built using the older framework. (Microsoft worked around this issue by making the 3.0 and 3.5 Frameworks additions to the 2.0 Framework.)
Unlike previous versions of the .NET framework, a feature of the .NET 4.0 Framework allows it to exist In-Process Side-by-Side with the .NET 2.0 Framework. This means that a process can use both versions of the framework at the same time. As a result, any managed 3.5 Framework and Component Object Model (COM) components will run within the 3.5 Framework, allowing you to leverage the new .NET 4.0 Framework functionality without having to worry about compatibility issues with the new version of the framework.

Using the Embed Interop Types property on referenced assemblies

Embed Interop Types is a new feature of the .NET 4.0 Framework that allows you to include the attribute information that is normally stored in the Primary Interop Assembly (PIA) in the executable or dynamic-link library (DLL) instead. This was introduced because deployment of managed solutions built on certain COM-based technologies was difficult because the deployment and verification of the PIA was also done on the target machine.
By default, when you add a PIA to a Visual Studio 2010 .NET 4.0 project without using the Add ArcGIS Reference plug-in, the PIA's Embed Interop Types property is set to true. The best practice is to change this setting to false when deploying customizations for ArcGIS, because the ArcGIS installer lays down the appropriate PIAs and assemblies on the system; you should not include any with your solution.






Development licensing Deployment licensing
ArcGIS for Desktop Basic ArcGIS for Desktop Basic
ArcGIS for Desktop Standard ArcGIS for Desktop Standard
ArcGIS for Desktop Advanced ArcGIS for Desktop Advanced
Engine Developer Kit Engine