简体   繁体   中英

C# Entity Framework resources and assembly resolve (appdomain)

I am facing a problem that I can't seem to explain what is going on.

It is likely that if I use AppDomain.AssemblyResolve event in my DLL(C#) and I use Entity Framework, somehow, I see it tries to load the following resource file:

EntityFramework.resources, Version=6.0.0.0, Culture=fr-FR, PublicKeyToken=b77a5c561934e089

and after

EntityFramework.resources, Version=6.0.0.0, Culture=fr, PublicKeyToken=b77a5c561934e089

I can't figure out where they could reside and neither if they exist somewhere. I can't find any discussion or Microsoft site talking about that.

For sure, everything works well if I return null in my event for that resources as state in Microsoft's documentation on AssemblyResolve event but the problem is that I would like to be able to not return null because there is another DLL (built before .NET 4) that is done by an external company and use in the same application than my DLL that will try to load the assembly resource file and throw an exception which makes the application crash.

For that reason, I,m trying to understand how to handle that particular case and avoid returning null.

Does someone have any explanation why Entity Framework would try to load those resources files and if there is a way to handle this without returning null from aassemblyresolve ?

I figured it out myself.

The solution is simple.

When asked for EntityFramework.resources , simply return the "already" loaded EntityFramework instance from the current AppDomain instead of using LoadFrom/Load/LoadFile methods.

Hope this helps someone in the future.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM