none
.Net framework 3.5 SP1 application fails to run on .NET framework 4.0. RRS feed

  • Question

  • We have a developed some PowerShell cmdlets in C# using Visual Studio 2008 / .NET framework 3.5 SP1. When we try to execute the cmdlet on a Windows XP or Windows 2003 server that has .NET framework 4.0 installed, we get the following error:

     

    Could not load file or assembly 'System.Core, Version=3.5.0.0, Cul

    ture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The

    system cannot find the file specified.

     

    Note that this machine does NOT have .NET framework 3.5 installed on it. .NET framework 4.0 is directly installed without installing 3.5. I do not see System.Core.dll in the GAC.

     

    On the other hand, if we first install .NET 3.5 and then install .NET 4.0, we do see System.Core in GAC and there are no issues.

     

    Is this expected behavior? Doesn't .NET framework 4.0 installer install all the binaries from 3.5 SP1 as well?

     

    Please advise.

     

    Thanks for your help,

    Anagha

    Tuesday, September 28, 2010 8:44 PM

Answers

  • Hi Anagha,

    Yes, as you observe, this behavior is by design.

    If your machine only has the .NET Framework version 4.0 installed, applications built against a previous .NET Framework won't run implicitly. To enable them to run you need to add the following to the application config file:

     
    <SUPPORTEDRUNTIME version="v4.0" />

    In this thread, Karel explained the reasons in detail:

    http://social.msdn.microsoft.com/Forums/en-US/netfxgeneralprerelease/thread/406a9a61-1904-44f7-bc05-d809d78e7938

    "This is actually by design. The goal of 4.0 is that by installing 4.0 on your machine nothing should change for applications which are not targetting 4.0 explicitly (so if they failed because no .NET Framework was installed before, they should keep failing after installing 4.0). It is part of an attempt to make the installation as much non-impactful as possible.

    Another motivation is that 4.0 is a major .NET Framework release and as such has much higher chance of introducing breaking changes (e.g. because further improvement in some feature areas required certain breaking changes by design). Therefore unless an application is tested against 4.0 (in which case it has supportedRuntime=v4.0.*), it is better not to run it on 4.0 rather than taking the chances and failing the app later because of the breaking changes.

    Furthermore this situation should really happen only on Windows XP and Windows 2003 OS, because Vista, Windows 2008 and Win7 all contain .NET Framework 2.0 or higher as part of OS installation."

    Thanks.


    Figo Fei
    MSDN Subscriber Support in Forum
    If you have any feedback on our support, please contact msdnmg@microsoft.com 


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    • Marked as answer by Anagha_12 Thursday, September 30, 2010 5:20 PM
    • Edited by Figo Fei Friday, October 1, 2010 2:42 AM
    Thursday, September 30, 2010 7:42 AM

All replies

  • Hi Anagha,

    Yes, as you observe, this behavior is by design.

    If your machine only has the .NET Framework version 4.0 installed, applications built against a previous .NET Framework won't run implicitly. To enable them to run you need to add the following to the application config file:

     
    <SUPPORTEDRUNTIME version="v4.0" />

    In this thread, Karel explained the reasons in detail:

    http://social.msdn.microsoft.com/Forums/en-US/netfxgeneralprerelease/thread/406a9a61-1904-44f7-bc05-d809d78e7938

    "This is actually by design. The goal of 4.0 is that by installing 4.0 on your machine nothing should change for applications which are not targetting 4.0 explicitly (so if they failed because no .NET Framework was installed before, they should keep failing after installing 4.0). It is part of an attempt to make the installation as much non-impactful as possible.

    Another motivation is that 4.0 is a major .NET Framework release and as such has much higher chance of introducing breaking changes (e.g. because further improvement in some feature areas required certain breaking changes by design). Therefore unless an application is tested against 4.0 (in which case it has supportedRuntime=v4.0.*), it is better not to run it on 4.0 rather than taking the chances and failing the app later because of the breaking changes.

    Furthermore this situation should really happen only on Windows XP and Windows 2003 OS, because Vista, Windows 2008 and Win7 all contain .NET Framework 2.0 or higher as part of OS installation."

    Thanks.


    Figo Fei
    MSDN Subscriber Support in Forum
    If you have any feedback on our support, please contact msdnmg@microsoft.com 


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    • Marked as answer by Anagha_12 Thursday, September 30, 2010 5:20 PM
    • Edited by Figo Fei Friday, October 1, 2010 2:42 AM
    Thursday, September 30, 2010 7:42 AM
  • Thanks for the clarification, Figo! It should be explicitly documented on MSDN though, as it is somewhat different from previous .NET versions.

     

     

    Thursday, September 30, 2010 5:22 PM
  • Hi Figo:

     

    I just got a new Dell xps with Win7, it does not have .net 3.5 on it, just 4.0.

    So Win7 does not automatically come with .net 3.5 I guess.

    When I try to install .net 3.5 sp1, nothing happens, I click to run it and nada. I have tried multiple times and it does not show up under my installed programs.

    I even tried the full package update and it says it fails to install.

    What do I need to do to get 3.5 on my pc?


    Thursday, August 11, 2011 9:09 PM
  • Hi girldev,

    Same problem here.  I'm trying to run SSRS and the Report Builder will not run.  When I try to run it, it returns a message saying .Net 3.5 has to be intalled but I have 4 on my Win7 machine. 

    When I run .Net 3.5 nothing happens though.  Did you find a resolution?

     

    Wednesday, May 30, 2012 3:40 AM