Running NetCF v1 Applications on v2 - Part II
Several months ago, I posted on using an application configuration file to instruct your NetCF v1 application to run against NetCF v2. As with Beta 1, this file must be named <appname>.exe.config and must be located in the same directory as your application (ex: myapp.exe.config must be in the same directory as myapp.exe). With the release of NetCF v2 Beta2, the application configuration file has a new option - compatibilityversion.
In his Loader Logging post, Steven Pratschner mentioned a "coercion state". He defined this as indicating "whether or not your application was run in backwards compatibility mode". You can specify this compatibility mode using the application configuration file. Steven also has an excellent post that details NetCF application compatibility and configuration files.
Basic configuration file
At it's simplest, the Beta 2 application configuration file is the same as for Beta 1. You supply the desired runtime version using a supportedRuntime XML node:
<configuration>
<startup>
<supportedRuntime version="v2.0.5056"/>
</startup>
</configuration>
The example above was copied from my original post and the version attribute was updated to specify Beta 2's version (2.0.5056).
Adding compatibility mode
Using the example above to run an application built using version 1 of the .NET Compact Framework will result in a compatibilityversion setting of 1.0 to ensure maximum compatibility.
If you wish to explicitly specify the compatibility mode for your application, you can add the compatibilityversion XML node to the above example:
<configuration>
<runtime>
<compatibilityversion major="1" minor="0"/>
</runtime>
<startup>
<supportedRuntime version="v2.0.5056"/>
</startup>
</configuration>
This new application configuration file is functionally equivalent to the previous example. The application will be run against NetCF v2 Beta 2 in NetCF v1 compatibility mode.
There are times when you may wish to have your NetCF v1 application run on NetCF v2 in it's native compatibility mode (as if the application were built against NetCF v2). To do so, you need to override the default behavior by specifying v2 in the compatibilityversion XML node. Please note: Use the following configuration file for diagnostic purposes only.
<configuration>
<runtime>
<compatibilityversion major="2" minor="0"/>
</runtime>
<startup>
<supportedRuntime version="v2.0.5056"/>
</startup>
</configuration>
One of our primary goals for NetCF v2 is compatibility. After you download and install beta 2, it would be much appreciated if you would run your NetCF v1 application(s) on NetCF v2 beta 2 using one of the above application configuration files. If you find any issues, please report them via the Microsoft Product Feedback Center along with the compatibilityversion (if any) specified in your application configuration file. We take application compatibility very seriously and look forward to receiving your results.
Thanks and enjoy the beta!
-- DK
[Edit: fix formatting *2]
[Edit: add link to second Steven Pratschner post]
Disclaimer(s):
This posting is provided "AS IS" with no warranties, and confers no rights.
Some of the information contained within this post may be in relation to beta software. Any and all details are subject to change.
Comments
Anonymous
April 24, 2005
Blog link of the week 16Anonymous
August 13, 2005
Bug in Substring under netcfAnonymous
February 24, 2006
I've talked before about application configuration file support in the .NET Compact Framework version...Anonymous
January 04, 2008
PingBack from http://drinks.247blogging.info/?p=29Anonymous
January 05, 2008
PingBack from http://boxing.247blogging.info/?p=2611Anonymous
January 21, 2009
PingBack from http://www.keyongtech.com/461953-how-to-get-cf-2-a