1

Project A uses entity framework 4.4.0.0 and has below entry in web.config

<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />

Project B uses entity framework 6.0.0.0 and has below entry in web.config

<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />

Project B is hosted under Project A in IIS (Project B was virtual directory, later converted to web application)

If I access project B, it shows message in browser that there is duplicate entry of entity framework.

I commented entry in project B

<!--<section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" />-->

This makes Project B run, but as soon it access data from database, an exception is thrown.

An error occurred creating the configuration section handler for entityFramework: Could not load file or assembly 'EntityFramework, Version=4.4.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies.

I cant edit Project A EF or Project B EF, as I don't have access

Any suggestions on how to deal with this?

CodeCaster
  • 147,647
  • 23
  • 218
  • 272
Amit Kumar
  • 591
  • 2
  • 8
  • 24
  • You're trying to do something like this? http://stackoverflow.com/questions/2460542/using-different-versions-of-the-same-assembly-in-the-same-folder#2461746 – Alexander Derck Dec 01 '15 at 09:37
  • 1
    I don't understand what is parent and child application, or what its to host an app under another.What is it all about? What do you do when it says "duplicate entry"? What is that "duplicate entry"? Try to improve your question, please. – JotaBe Dec 01 '15 at 09:38
  • Thank you @AmitKumar perhaps it was my fault to not understand the question, but now the question is perfect. I hope my answer helps you. – JotaBe Dec 01 '15 at 12:49

1 Answers1

1

You can do that by disallowing inheritance of the section. To do so, you can add this atribute to what shouldn't be inherited in the parent web.config: inheritInChildApplications="false"

As explained here not all elements suport it, so perhaps you have to do it in a parent, and redefined all the other things that should be inherited: How to stop inheritance of <configSections>in Web.Config This is a good solution for it: Avoid web.config inheritance in child web application using inheritInChildApplications

You can also see the 7th tip of this asp.net log: 10 Things ASP.NET Developers Should Know About Web.config Inheritance and Overrides

Community
  • 1
  • 1
JotaBe
  • 38,030
  • 8
  • 98
  • 117
  • it was helpful.. but they say you cannot use this on config section – Amit Kumar Dec 01 '15 at 14:45
  • use the location trick in http://stackoverflow.com/questions/782252/avoid-web-config-inheritance-in-child-web-application-using-inheritinchildapplic Wrapping with the dot location, i.e. `location path='.'`, refers to the same place where the .config file is. That solves your problem. – JotaBe Dec 01 '15 at 17:41
  • I did
    It Says Unrecognized element 'location'
    – Amit Kumar Dec 02 '15 at 06:16
  • Wrap the `configSections` with `location`, not the other way. In fact, I don't have a config file to check it, bu you perhaps have to wrap some more tags with `location`. In other ways, use `location` wher it's accepted, and wrap all the tags from that same level, no more, no less. – JotaBe Dec 02 '15 at 08:40