none
ResolveEventHandler issue when migrating from .NET 3.5 to 4.0 RRS feed

  • Question

  • Hi,

    We are moving to .NET 4.0. Our application is using ResolveEventHandler to load the proper assemblies (based on some XML files, so we could have multiple versions).

    We do not have separate resources - all is embedded in the executables/dlls.

    We have got a nice "AppName.resources" file-not-found exceptions when the resources are to be loaded.

    What I figured out was that that from .NET 4.0 this delegate is called back for RESOURCE assemblies as well -  so getting this exception is a kind of "feature" [http://msdn.microsoft.com/en-us/library/system.resolveeventhandler(v=vs.100).aspx]

    The questions here are:

    1. Why the delegate is called with the "AppName.resources" file at all? [OK, it should be because this way locale-specific applications can decide what to load]

    2. What assembly to return if the is no separate assembly at all [e.g. resources are embedded in the executable]?

    3. Is it just sheer luck that returning the assembly where the delegate's code is, works?

    4. Returning the assembly of where the resource really is does not work. Why? Is there any explanation to this? 

    Thanks in advance

    -seci




    • Edited by pselmeczy Wednesday, July 30, 2014 2:02 PM
    Wednesday, July 30, 2014 2:00 PM

Answers

All replies

  • What I figured out is that returning null works.

    But "or null if the assembly cannot be resolved." should be a bit more clear in the documentation, e.g. should tell to return null if the resource is embedded in the executable.

    But it is still no explanation why returning the assembly where there resource really is located fails, and why returning an absolutely irrelevant assembly works.
    • Edited by pselmeczy Wednesday, July 30, 2014 2:31 PM
    Wednesday, July 30, 2014 2:16 PM
  • HI Pselmeczy,

    You can refer to the following link to see details about load embedded assembly in C# app. http://www.codeproject.com/Articles/528178/Load-DLL-From-Embedded-Resource.

    You can also see how the runtime locates assemblies from http://msdn.microsoft.com/en-us/library/yx7xezcf(v=vs.110).aspx. But I think there is different between normal assembly and embedded assembly.

    Regards,


    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. <br/> Click <a href="http://support.microsoft.com/common/survey.aspx?showpage=1&scid=sw%3Ben%3B3559&theme=tech"> HERE</a> to participate the survey.

    Thursday, July 31, 2014 5:54 AM
    Moderator