Parser Error: It is an error to use a section registered as allowDefinition = MachineToApplication...

Problem

You get this error when attempting to run your application:

Configuration Error

Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message: It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS.

You may also encounter this error:

The type or namespace '<namespace name>' does not exist in the class or namespace '<parent namespace>' (are you missing an assembly reference?)"

There are several causes of this error which are described below.

You do not have a virtual directory for your application

This error typically occurs when your application does not have a virtual directory established in the Microsoft IIS web server.  Your application needs a virtual directory in order to run.  See Creating a Virtual Directory for Your Application for instructions on creating a virtual directory.  When you create the Virtual Directory on Windows 2003, you must select the “Run Scripts (such as ASP)” in the Virtual Directory Creation Wizard.

Please also check that the .NET Framework version of your application is correctly specified in the virtual directory settings.

The folder containing your application is within the root folder of your website

For example, if your root website is located in C:\inetpub\wwwroot and it contains a Web.config file and you installed your application in C:\inetpub\wwwroot\MyApp and it also contains a Web.config, then your application’s Web.config file is considered a nested or inherited Web.config file.  Web.config files can be nested, however nested Web.config files cannot contain some elements such as the <authentication mode=...>, <httpHandlers> and <httpModules> parameters.  Iron Speed Designer creates a Web.config file for your application assuming it is a completely ‘free-standing’ application instead of being part of a larger application and your application does not require the presence of another root Web.config file to run.

This can be resolved in a number of ways, but typically the best solution is to move your application to its own folder outside of the web root folder, such as C:\MyApp, and you change your virtual directory setting for MyApp to point to this folder.  Other ways to address this (not recommended) are to (a) change your Machine.config file to allow "full" Web.config files in nested sub-folders, (b) delete the Web.config file from the web root folder assuming you do not need it; or (c) modify your application's Web.config to remove the authentication, httpHandlers and httpModules sections in order to make your application a subset of the web root application and inherit all of the other settings from the root.

Windows 2003 Application Pool configuration

If you are running Windows 2003, this error is caused by not enabling your virtual directory to Run Scripts or not creating an Application Pool for the application.

On Windows 2003 Servers, make sure that the Application Pool you are using is specific to the .NET version.  For example, if your web root is using the Default App Pool and is configured to use .NET Framework 1.1, and your application is configured to use .NET Framework 2.0, then you cannot use the same application pool.  Create a new application pool for .NET Framework 2.0 applications and specify this pool when setting the properties of the virtual directory for your application.

See Also

Part VII:  Troubleshooting Applications

Application Will Not Run

Application Runs But No Data is Displayed

Application Error Messages