none
Application uses .Net Framework 4.0, although is was build with 2.0 RRS feed

  • Question

  • At one of our customers, our application, that was build with the .Net Framework 2.0, always gets started with .Net Framework 4.0.

    This causes a crash in a 3rd party assembly (Telerik).

    We already created a CLR Load Log:

    5568,1726707.515,CLR Loading log for C:\Program Files (x86)\windream GmbH\windream\Windream.Find.WinForms.exe
    5568,1726707.515,Log started at 09:26:15 on 07.01.2016
    5568,1726707.515,-----------------------------------
    5568,1726707.515,FunctionCall: _CorExeMain
    5568,1726707.515,FunctionCall: ClrCreateInstance, Clsid: {2EBCD49A-1B47-4A61-B13A-4A03701E594B}, Iid: {E2190695-77B2-492E-8E14-C4B3A7FDD593}
    5568,1726707.515,MethodCall: ICLRMetaHostPolicy::GetRequestedRuntime.  Version: (null),  Metahost Policy Flags: 0x1168, Binary: (null), Iid: {BD39D1D2-BA2F-486A-89B0-B4B0CB466891}
    5568,1726707.515,Installed Runtime: v2.0.50727.  VERSION_ARCHITECTURE: 0
    5568,1726707.515,Installed Runtime: v4.0.30319.  VERSION_ARCHITECTURE: 0
    5568,1726707.515,Input values for ComputeVersionString follow this line
    5568,1726707.515,-----------------------------------
    5568,1726707.515,Default Application Name: C:\Program Files (x86)\windream GmbH\windream\Windream.Find.WinForms.exe
    5568,1726707.515,IsLegacyBind is: 0
    5568,1726707.515,IsCapped is 0
    5568,1726707.515,SkuCheckFlags are 0
    5568,1726707.515,ShouldEmulateExeLaunch is 0
    5568,1726707.515,LegacyBindRequired is 0
    5568,1726707.515,-----------------------------------
    5568,1726707.515,Parsing config file: C:\Program Files (x86)\windream GmbH\windream\Windream.Find.WinForms.exe.config
    5568,1726707.515,Config File (Open). Result:00000000
    5568,1726707.515,Config File (Read). Result:00000000
    5568,1726707.515,Found config file: C:\Program Files (x86)\windream GmbH\windream\Windream.Find.WinForms.exe.config
    5568,1726707.515,UseLegacyV2RuntimeActivationPolicy is set to 0
    5568,1726707.515,FindLatestVersion is returning the following version: v4.0.30319 Input VERSION_ARCHITECTURE: 0, V2.0 Capped: 0
    5568,1726707.515,Default version of the runtime on the machine: v4.0.30319
    5568,1726707.515,Decided on runtime: v4.0.30319

    ...

    As you can see, the Version, the application was build with, is not taken into account.

    Why ? Is there any Setting, that may cause this ?

    We than decided to put a define the Framework Version to use in a config file, using supportedRuntime.

    The result is the following CLR Load Log:

    312,1810559.703,CLR Loading log for C:\Program Files (x86)\windream GmbH\windream\Windream.Find.WinForms.exe
    312,1810559.703,Log started at 08:43:49 on 08.01.2016
    312,1810559.703,-----------------------------------
    312,1810559.703,FunctionCall: _CorExeMain
    312,1810559.703,FunctionCall: ClrCreateInstance, Clsid: {2EBCD49A-1B47-4A61-B13A-4A03701E594B}, Iid: {E2190695-77B2-492E-8E14-C4B3A7FDD593}
    312,1810559.718,MethodCall: ICLRMetaHostPolicy::GetRequestedRuntime.  Version: (null),  Metahost Policy Flags: 0x1168, Binary: (null), Iid: {BD39D1D2-BA2F-486A-89B0-B4B0CB466891}
    312,1810559.718,Installed Runtime: v2.0.50727.  VERSION_ARCHITECTURE: 0
    312,1810559.718,Installed Runtime: v4.0.30319.  VERSION_ARCHITECTURE: 0
    312,1810559.718,Input values for ComputeVersionString follow this line
    312,1810559.718,-----------------------------------
    312,1810559.718,Default Application Name: C:\Program Files (x86)\windream GmbH\windream\Windream.Find.WinForms.exe
    312,1810559.718,IsLegacyBind is: 0
    312,1810559.718,IsCapped is 0
    312,1810559.718,SkuCheckFlags are 0
    312,1810559.718,ShouldEmulateExeLaunch is 0
    312,1810559.718,LegacyBindRequired is 0
    312,1810559.718,-----------------------------------
    312,1810559.718,Parsing config file: C:\Program Files (x86)\windream GmbH\windream\Windream.Find.WinForms.exe.config
    312,1810559.718,Config File (Open). Result:00000000
    312,1810559.718,Config File (Read). Result:00000000
    312,1810559.718,Found config file: C:\Program Files (x86)\windream GmbH\windream\Windream.Find.WinForms.exe.config
    312,1810559.718,UseLegacyV2RuntimeActivationPolicy is set to 0
    312,1810559.718,Config file includes SupportedRuntime entry.  Version: v2.0.50727, SKU: (null)
    312,1810559.718,FindLatestVersion is returning the following version: v4.0.30319 Input VERSION_ARCHITECTURE: 0, V2.0 Capped: 0
    312,1810559.718,Default version of the runtime on the machine: v4.0.30319
    312,1810559.718,Decided on runtime: v4.0.30319

    It even sees the SupportedRuntime in the config file, but still decides to use the wrong runtime Version.

    Does anybody know a possible reason for this strange behaviour ?

    Additional info: the machine is running Server 2012 R2 with Citrix XenApp 6.5

    Regards,

      Uwe Honermann

      windream GmbH

    Monday, January 11, 2016 12:05 PM

Answers

  • Looks like we found the solution:

    [HKLM\SOFTWARE\Microsoft\.NETFramework]
    "OnlyUseLatestCLR" = 1

    See also:

    http://blogs.msdn.com/b/selvar/archive/2012/07/14/reporting-services-unexpectedly-loads-net-framework-4-0-by-default-and-fails-with-http-500-19-while-browsing-report-server-and-report-manager-url.aspx

    Tuesday, January 12, 2016 11:04 AM

All replies

  • How about the following app.config ?

    <configuration>
      <startup useLegacyV2RuntimeActivationPolicy="true">
        <supportedRuntime version="v4.0" />
      </startup>
    </configuration>
    


    Monday, January 11, 2016 2:32 PM
  • But it is the best that your program will be run on .NET framework 3.5.1 or 3.5 SP1 if all modules including the third party's modules was build with .NET 2.0.

    Monday, January 11, 2016 2:44 PM
  • I tried that, but with that config, the application even crashes on my own Systems, because it uses the Framework 4.

    It only works, when running with Framework 2.0.

    Monday, January 11, 2016 2:47 PM
  • I did this in my project. All the references of your project must point to .Net framework 2.0, compile project under .Net frework 2.0. If you are using 3rd party control like Telerik, then download their .Net framework 2.0 controls.

    All DLL and exe must use framework 2.0. Right click on each DLL and see the RunTime Version. If its different then 2.0 then remove it and add the 2.0 version. Even if one DLL is used framework 3.5 or 4.0. You'll see this error.

    Monday, January 11, 2016 2:51 PM
  • Everything is build with .Net Framework 2.0, and it is running perfectly on hundreds of Systems.

    Only this one System is always using Version 2.0.

    One thing, that is very interesting, is, that the loader doesn't even read the Version, the application was build with.

    These lines are completely missing:

    3220,172682.919,LegacyFunctionCall: GetFileVersion.  Filename: C:\Program Files\windream GmbH\windream\Windream.Find.WinForms.exe
    3220,172682.919,LegacyFunctionCall: GetFileVersion.  Filename: C:\Program Files\windream GmbH\windream\Windream.Find.WinForms.exe
    3220,172682.919,C:\Program Files\windream GmbH\windream\Windream.Find.WinForms.exe was built with version: v2.0.50727

    Monday, January 11, 2016 2:55 PM
  • Is machine.config correct ?
    Monday, January 11, 2016 3:51 PM
  • I currently told the customer to send me all machine.config files unter c:\windows\Microsoft.NET.

    Although I wonder, if such a redirection shouldn't be visible in the CLR Load Log.

    Monday, January 11, 2016 3:54 PM
  • Hi windream,

    I am not well know about (Telerik), based on your scenario, you can check the table of .NET Framework Versions and Dependencies. Each version of the .NET Framework contains the common language runtime (CLR), the base class libraries, and other managed libraries.

    Please note the CLR version column, CLR version changed when .Net framework becomes 4.0. I suspect that maybe Telerik only support CLR2.0 at runtime, as it only works when running with Framework 2.0.You may have a check about this product.

    Have a nice day!

    Kristin


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Tuesday, January 12, 2016 6:27 AM
  • Hi Kristin,

    you're right, the Telerik Controls we use only support .Net Framework 2.0, and we know that.

    Because of that, we want the application to run under .Net Framework 2.0, but the customer's Server 2012 R2 machine doesn't do that.

    Instead, it always starts our application with .Net Framework 4.0.

    The big question is: why does it do that ?
    Why doesn't it even check the version, the application was build with ?
    Why does it read the supportedRuntime from the config file, but then ignores it ?

    Regards,
       Uwe

    Tuesday, January 12, 2016 8:32 AM
  • Because of that, we want the application to run under .Net Framework 2.0, but the customer's Server 2012 R2 machine doesn't do that.

    @Uwe,

    Does the  Server 2012 R2 machine enable .NET Framework 3.5? If not, please refer to http://www.danielclasson.com/install-net-framework-35-server-2012/

    >>Why doesn't it even check the version, the application was build with ?

    It depends on your project target .Net framework. )

    >>Why does it read the supportedRuntime from the config file, but then ignores it ?
                                                                                                                                      
    I've checked <supportedRuntime> Element  from MSDN.  In remarks section,   When multiple versions of the runtime are supported, the first element should specify the most preferred version of the runtime, and the last element should specify the least preferred version.For more inforamtion, please check https://msdn.microsoft.com/library/w4atty68(v=vs.100).aspx

    Best regards,

    Kristin


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    • Edited by Kristin Xie Tuesday, January 12, 2016 8:44 AM
    Tuesday, January 12, 2016 8:44 AM
  • Hi Kristin,

    as you can see in the CLR Load Logs posted:

    312,1810559.718,Installed Runtime: v2.0.50727.  VERSION_ARCHITECTURE: 0
    312,1810559.718,Installed Runtime: v4.0.30319.  VERSION_ARCHITECTURE: 0

    from the config file:

    312,1810559.718,Config file includes SupportedRuntime entry.  Version: v2.0.50727, SKU: (null)

    But still:

    312,1810559.718,Decided on runtime: v4.0.30319

    Regards,
       Uwe

    Tuesday, January 12, 2016 9:00 AM
  • The line:

    312,1810559.718,FindLatestVersion is returning the following version: v4.0.30319 Input VERSION_ARCHITECTURE: 0, V2.0 Capped: 0

    shouldn't even appear after:

    312,1810559.718,Config file includes SupportedRuntime entry.  Version: v2.0.50727, SKU: (null)

    because the .Net Framework to use should be clear with that line.

    Tuesday, January 12, 2016 9:04 AM
  • Looks like we found the solution:

    [HKLM\SOFTWARE\Microsoft\.NETFramework]
    "OnlyUseLatestCLR" = 1

    See also:

    http://blogs.msdn.com/b/selvar/archive/2012/07/14/reporting-services-unexpectedly-loads-net-framework-4-0-by-default-and-fails-with-http-500-19-while-browsing-report-server-and-report-manager-url.aspx

    Tuesday, January 12, 2016 11:04 AM
  • @windream

    Glad to hear you have worked it out, and thanks for sharing your solution here.

    Please also remember to close this thread by marking your reply as an answer.

    Happy new year!

    Kristin


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    • Edited by Kristin Xie Thursday, January 14, 2016 6:46 AM
    Wednesday, January 13, 2016 9:29 AM
  • Looks like we found the solution:

    [HKLM\SOFTWARE\Microsoft\.NETFramework]
    "OnlyUseLatestCLR" = 1

    See also:

    http://blogs.msdn.com/b/selvar/archive/2012/07/14/reporting-services-unexpectedly-loads-net-framework-4-0-by-default-and-fails-with-http-500-19-while-browsing-report-server-and-report-manager-url.aspx

    Hi , why don't we have it in our registery? your answer would be appreciated.

    Tuesday, August 8, 2017 7:04 AM