A section registered as allowDefinition = 'MachineToApplication' exceeding the application level

After adding assebly to System.Data.Entity to my web configuration, I got this error: Error using a section registered as allowDefinition = 'MachineToApplication' that exceeds the application level. This error can be caused by the fact that the virtual directory is not configured as an application in IIS.

I deleted the obj and bin folders, I deleted the authentication = "windows" line, tried to open it again, as some said it worked, I checked that there is only 1 web.config in the main folder (Entity Framework - Folder for forms, models , DAL and BLL) ...

What other reasons for this to happen? I searched everywhere, and basically these were the reasons I found ....

This is my web.config, if that matters:

<configuration> <connectionStrings> <add name="ApplicationServices" connectionString="data source=.\SQLEXPRESS;Integrated Security=SSPI;AttachDBFilename=|DataDirectory|\aspnetdb.mdf;User Instance=true" providerName="System.Data.SqlClient" /> <add name="CStringVKB" connectionString="Data Source=.;Initial Catalog=VKB;Persist Security Info=True;User ID=websiteservice;Password=websiteservice" providerName="System.Data.SqlClient" /> </connectionStrings> <system.web> <compilation debug="true" optimizeCompilations="true" targetFramework="4.0" > <assemblies> <add assembly="System.Data.Entity, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" /> </assemblies> </compilation> <!--<authentication mode="Windows"> <forms loginUrl="~/Account/Login.aspx" timeout="2880" /> </authentication>--> <membership> <providers> <clear/> <add name="AspNetSqlMembershipProvider" type="System.Web.Security.SqlMembershipProvider" connectionStringName="ApplicationServices" enablePasswordRetrieval="false" enablePasswordReset="true" requiresQuestionAndAnswer="false" requiresUniqueEmail="false" maxInvalidPasswordAttempts="5" minRequiredPasswordLength="6" minRequiredNonalphanumericCharacters="0" passwordAttemptWindow="10" applicationName="/" /> </providers> </membership> <profile> <providers> <clear/> <add name="AspNetSqlProfileProvider" type="System.Web.Profile.SqlProfileProvider" connectionStringName="ApplicationServices" applicationName="/"/> </providers> </profile> <roleManager enabled="false"> <providers> <clear/> <add name="AspNetSqlRoleProvider" type="System.Web.Security.SqlRoleProvider" connectionStringName="ApplicationServices" applicationName="/" /> <add name="AspNetWindowsTokenRoleProvider" type="System.Web.Security.WindowsTokenRoleProvider" applicationName="/" /> </providers> </roleManager> </system.web> <system.webServer> <modules runAllManagedModulesForAllRequests="true"/> </system.webServer> </configuration> 

What can I do to solve this problem?

+8
directory virtual entity-framework
source share
4 answers

Basically, an error means that in one of your subfolders there is a web.config file that has a configuration element that it should not have. Is this your root / only network file? If not, could you also post them?

Also, that sounds silly, but I would double check that you open the site itself in your IDE (and do not mistakenly open the parent folder). I saw people spend a couple of hours trying to debug the same error when they were all not in the correct directory.

Here is a good explanation of how the web.config hierarchy for ASP is set up to help you visualize how it works: http://scottonwriting.net/sowblog/archive/2010/02/17/163375.aspx

+23
source share

Apparently in my solution there were two web.config files. I am using MVC4, and there was another configuration file in the Views section, and I was making changes to the wrong file. Fixed it helped me.

But you can always change the default redirection / route in the global.asax file.

+1
source share

This problem most often occurs when you open a site in Visual Studio, but accidentally open the parent of the root folder. For example, imagine you have a website located in C: \ MyProjects \ Website1, where the Website1 folder is the root of the website. When you open this website from Visual Studio, you are prompted to specify the root folder of the website - be sure to select the Website1 folder. If you accidentally selected the MyProjects folder, the Web.config file in the Website1 folder is now located in one of the subfolders of the website. Since this Web.config file includes this element, among other parameters at the application level you will receive the above error.

The fix for this error (in most cases) is to close the project and reopen it from Visual Studio, making sure you select the appropriate folder.

Happy programming!

0
source share

Chris Noreikis answer is actually correct. But an important detail is missing. If for any reason you open a project / solution in a different version of VS than was originally created, VS will try to migrate. Sometimes during this migration, VS creates a folder called "backup" or "backup _ {#}". Even if you cancel pending changes , it reassigns these directories.

The presence of these directories in some cases (for example, mine) is the cause of this error. Removing these directories will fix the problem.

My hope is that it saves someone the countless hours that I have lost on this issue.

0
source share

All Articles