Running .NET 3.5 Application on .NET 4 (And Beyond)

Few days ago I tried to get my VHD Attach to run on Windows Thin PC.

Initial diagnosis was easy - there was no .NET Framework installed. While there is no way to install .NET Framework 3.5 on Windows Thin PC, .NET Framework 4.0 installs just fine.

Next run gave us another clue with System.IO.FileNotFoundException: Could not load file or assembly 'System.ServiceModel, Version=3.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The system cannot find the file specified.

While .NET 4 is backward compatible, Microsoft made intentional decision that it will not run applications made with earlier runtimes. This is not a big issue in Windows 7. There you have 2.0, 3.5 and 4.0 installed side-by-side and each application can pick whatever it needs. However, in Windows Thin PC there is only 2.0 and 4.0. Notice that one version is missing and it was the one I needed.

To make long story short, there is solution that does not involve recompiling. Just add Application Configuration Files (App.config) and put following text into it:
[xml]
<?xml version="1.0"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" />
<supportedRuntime version="v2.0.50727" />
</startup>
</configuration>
[/xml]

This will tell application to run on .NET 4 if possible and to fallback to 3.5, 3.0 and 2.0 as a backup solution. This might not be most beautiful solution but it is a solution that works.

P.S. Yes, supportedRuntime cannot distinguish between .NET 2.0, 3.0 and 3.5.

2 thoughts to “Running .NET 3.5 Application on .NET 4 (And Beyond)”

  1. I found some tips on how to add or remove packages to the “Thin PC” OS.

    It includes the packages:
    01. .NET Framework 3.5 with Client Profile
    02. Premium Codecs for Windows Media Player
    03. Windows Search
    04. Windows DVD Maker
    05. Windows ISO Burner (Image Mastering API V2)
    06. Windows Media Center
    07. Windows Photo Viewer
    08. Speech and Text with Speech US English Pack
    09. Windows Defender
    10. Fax and Scan
    11. Mobility Center and SideShow
    12. Tablet PC Support
    13. Windows Backup and Restore

    There are two ways to install or add the required Feature Package to the Thin PC:
    – Online Method (Installing on an insalled Thin PC OS)
    – Offline Method (Integrating with the Thin PC DVD)

    Link:
    http://forums.mydigitallife.info/archive/index.php/t-28118.html

    I hope that helps!

Leave a Reply

Your email address will not be published. Required fields are marked *