none
App loads in .Net 4.5 but not in 4.6 RRS feed

  • Question

  • I get the following event log error when loading my app in a machine with .Net 4.6 (either Win 2008 R2 or Win 10).

    The app is targeted to .Net 4.5, and loads fine in that version.

    Event source: .Net Runtime

    Application: foo.exe

    Framework Version: v4.0.30319
    Description: The process was terminated due to an unhandled exception.
    Exception Info: System.IO.FileNotFoundException
    Stack:
       at System.ModuleHandle.ResolveType(System.Reflection.RuntimeModule, Int32, IntPtr*, Int32, IntPtr*, Int32, System.Runtime.CompilerServices.ObjectHandleOnStack)
       at System.ModuleHandle.ResolveType(System.Reflection.RuntimeModule, Int32, IntPtr*, Int32, IntPtr*, Int32, System.Runtime.CompilerServices.ObjectHandleOnStack)
       at System.ModuleHandle.ResolveTypeHandleInternal(System.Reflection.RuntimeModule, Int32, System.RuntimeTypeHandle[], System.RuntimeTypeHandle[])
       at System.Reflection.RuntimeModule.ResolveType(Int32, System.Type[], System.Type[])
       at System.Reflection.CustomAttribute.FilterCustomAttributeRecord(System.Reflection.CustomAttributeRecord, System.Reflection.MetadataImport, System.Reflection.Assembly ByRef, System.Reflection.RuntimeModule, System.Reflection.MetadataToken, System.RuntimeType, Boolean, System.Object[], System.Collections.IList, System.RuntimeType ByRef, System.IRuntimeMethodInfo ByRef, Boolean ByRef, Boolean ByRef)
       at System.Reflection.CustomAttribute.GetCustomAttributes(System.Reflection.RuntimeModule, Int32, Int32, System.RuntimeType, Boolean, System.Collections.IList, Boolean)
       at System.Reflection.CustomAttribute.GetCustomAttributes(System.Reflection.RuntimeAssembly, System.RuntimeType)
       at System.Attribute.GetCustomAttributes(System.Reflection.Assembly, System.Type, Boolean)
       at System.AppDomain.GetTargetFrameworkName()


    • Edited by JakeX Sunday, December 6, 2015 8:24 AM
    Sunday, December 6, 2015 8:14 AM

All replies

  • Hi Jake,

    >>App loads in .Net 4.5 but not in 4.6

    From your title, do you mean when you target your project to .Net 4.6, you'll meet the above event log error? Am I right? If yes, I am curious to know, why you target your project to both .4.5 and .4.6?

    This should be decided before you write your project first.

    Now do you try to debug your project? I would prefer you post some build errors here. It could be better to help us understand this issue.

    Based on your event log error, I see the Framework Version: v4.0.30319, but your target is 4.5 and 4.6. Please also have a check to make sure whether a problem here.

    In addition,  I've searched more, please check C# Application fails depending on which PC was used to compile it to see if it helps or not.

    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 Monday, December 7, 2015 3:34 AM
    Monday, December 7, 2015 3:32 AM
  • We don't change the target.

    The target is .Net 4.5, but the app doesn't load on a machine with 4.6 installed.

    The app builds fine, so there's no build errors to show.

    Tuesday, December 8, 2015 6:17 AM
  • Hi Jake,

    >>The target is .Net 4.5, but the app doesn't load on a machine with 4.6 installed.

    Here I found a nice blog that describes your scenario better.

    <Copied>

    The .NET Framework 4.6 is an in-place upgrade for all of the following versions of the .NET Framework:

    • .NET Framework 4
    • .NET Framework 4.5
    • .NET Framework 4.5.1
    • .NET Framework 4.5.2

    The .NET Framework 4.6 is designed to be compatible with all applications created with any version of the .NET Framework from 4 to 4.6, but there are sometimes application compatibility issues that arise, such as an installer that tells the user that they must install the .NET Framework 4.5 even if the .NET Framework 4.6 is already installed.  In cases like this, you might need to revert back from the .NET Framework 4.6 to an earlier version of the .NET Framework 4 family.  To do that, you must uninstall the .NET Framework 4.6 and then re-install the earlier version of the .NET Framework from the .NET Framework 4 family.

    The .NET Framework 4.6 comes installed as a part of the OS on Windows 10, and there is not a way to uninstall it.  If you run into an application compatibility issue with the .NET Framework 4 family on Windows 10, you cannot revert back to an earlier version of the .NET Framework 4 family by using the uninstall and re-install instructions that I listed above like you can on older versions of Windows.  In that scenario, I typically recommend contacting the application manufacturer to see if they have any patches available that will allow their application to install and run with the .NET Framework 4.6 installed.

    </Copied>

    Please also note that, maybe your scenario is runtime Changes in the .NET Framework 4.6

    The following link should helps

    https://msdn.microsoft.com/en-us/library/dn833125(v=vs.110).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 Thursday, December 10, 2015 2:11 AM
    Thursday, December 10, 2015 2:11 AM
  • Hi Kristin,

    I understand that a runtime change might cause this.

    Could you take a look at the stack trace, and help hypothesize what kind of a change might be responsible?

    Judging from the trace, it seems like TargetFrameworkName might be related, but the weird thing is that, when looking at GetTargetFrameworkName in ILSpy, it doesn't seem to throw any exceptions.
    • Edited by JakeX Thursday, December 10, 2015 8:30 AM More details
    Thursday, December 10, 2015 8:28 AM
  • Hi Jake,

    Sorry for my late reply.

    >>Judging from the trace, it seems like TargetFrameworkName might be related, but the weird thing is that, when looking at GetTargetFrameworkName in ILSpy, it doesn't seem to throw any exceptions.

    From above message, I am not sure your issue is TargetFrameworkName might be related.

    But maybe GetTargetFrameworkName call some other unmanaged code, it also will

    throw some exceptions

    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.



    • Edited by Kristin Xie Tuesday, December 15, 2015 2:05 AM
    Tuesday, December 15, 2015 2:01 AM