C# 部分注册为 allowDefinition='MachineToApplication' 超出应用程序级别

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1712629/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 20:11:13  来源:igfitidea点击:

section registered as allowDefinition='MachineToApplication' beyond application level

c#asp.netwindowsiis

提问by Christof

I am getting this error when I create a new folder, and upload files to it. I have an existing site that's built, but I don't want to add this to the site, but rather have it be an application all by itself. Any ideas?

创建新文件夹并向其中上传文件时出现此错误。我有一个现有的站点,但我不想将它添加到站点,而是让它自己成为一个应用程序。有任何想法吗?

采纳答案by Jeremy Morgan

I just had this problem not too long ago. Go into IIS, select the folder you created and go to properties. You will see "application name" greyed out, click the "create" button and save it. You will be able to run your separate application in it.

我不久前刚遇到这个问题。进入 IIS,选择您创建的文件夹并转到属性。您将看到“应用程序名称”变灰,单击“创建”按钮并保存。您将能够在其中运行您单独的应用程序。

回答by Ofer Zelig

This is indeed the first scenario to check. However, the most frustrating scenario in which this error occurs is after a build/publish under a different build configuration (i.e. build under Release, and then trying to build under Debug and getting this error). You should perform Clean operation on the Release mode.

这确实是要检查的第一个场景。但是,发生此错误的最令人沮丧的情况是在不同的构建配置下构建/发布之后(即在 Release 下构建,然后尝试在 Debug 下构建并出现此错误)。您应该在 Release 模式下执行 Clean 操作。

See this answer which points to further details: Error: allowDefinition='MachineToApplication' beyond application level

请参阅此答案,其中指出了更多详细信息:错误:超出应用程序级别的 allowDefinition='MachineToApplication'

回答by ayenco

I just solved such errors after hours of trying, I had the same scenario resolved by simply deleting any back up files your solution may have created moving your application from one version of visual studio to the other and the problem is resolved

经过数小时的尝试,我刚刚解决了此类错误,通过简单地删除您的解决方案可能创建的任何备份文件,将您的应用程序从一个版本的 Visual Studio 移动到另一个版本,我解决了同样的问题,问题就解决了

回答by Jomy John

I faced this issue many times. Different solutions worked in different occasions. Following are the solutions.

我多次遇到这个问题。不同的解决方案适用于不同的场合。以下是解决方案。

  1. Create an IIS application for your web site.
  2. Clean the solution and rebuilt again.
  3. Delete the obj folder and rebuilt again.
  1. 为您的网站创建一个 IIS 应用程序。
  2. 清洁溶液并再次重建。
  3. 删除 obj 文件夹并重新构建。

回答by Atif

Open IIS click right click on the folder and Click "Convert to Application"

打开 IIS 单击右键单击文件夹,然后单击“转换为应用程序”

回答by Hammad Khan

I had this problem when I moved my application from Window XP to Windows 7. The error is primarily because you did not convert your folder into Application.

当我将应用程序从 Window XP 移动到 Windows 7 时遇到了这个问题。错误主要是因为您没有将文件夹转换为应用程序。

The mistake that I was making was, when I selected the folder in IIS and right clicked, I choose "Add Application". This should be "Convert to Application". The resolved my problem.

我犯的错误是,当我在 IIS 中选择文件夹并右键单击时,我选择了“添加应用程序”。这应该是“转换为应用程序”。解决了我的问题。

You want to remove the application from your folder then do the process again and select "Convert to Application".

您想从文件夹中删除应用程序,然后再次执行此过程并选择“转换为应用程序”。

回答by Salil Gupta

The project folder you are accessing might be the incorrect one Which result in finding two webconfig file for a project. So try to open the correct website.

您正在访问的项目文件夹可能不正确,这导致为一个项目找到两个 webconfig 文件。所以尝试打开正确的网站。

回答by Scott

For what it's worth, while in development, I got this same error when using "Open Website" on a project that I created using "New Project". If I instead open with "Open Project", the error goes away.

值得一提的是,在开发过程中,我在使用“新项目”创建的项目上使用“打开网站”时遇到了同样的错误。如果我改为使用“打开项目”打开,错误就会消失。

回答by MongooseNX

I just faced this today...Here is my fix and understanding of it.

我今天刚刚面对这个问题......这是我对它的修复和理解。

  1. Right click on your webproject and 'unload' it.
  2. Edit your projects .csproj file (I assume .vs.proj in vb)
  3. Look for 'true'
  4. Change it to false.
  5. Save your .csproj
  6. Right Click on the .csproj and reload it.
  1. 右键单击您的 web 项目并“卸载”它。
  2. 编辑您的项目 .csproj 文件(我假设 .vs.proj 在 vb 中)
  3. 寻找“真实”
  4. 将其更改为假。
  5. 保存您的 .csproj
  6. 右键单击 .csproj 并重新加载它。

Hopefully fixes your problem.

希望能解决你的问题。

It's my understanding that the error you are getting is 'real', in my case in my web.config was causing the error, because this should actually be set on our server, not by the application.

我的理解是您得到的错误是“真实的”,就我而言,我的 web.config 导致了错误,因为这实际上应该在我们的服务器上设置,而不是由应用程序设置。

For some reason, reading Phil Haacks post help me to figure this out...I hope this helps others, I was unable to find a solution that met our needs while looking.

出于某种原因,阅读 Phil Haacks 的帖子可以帮助我解决这个问题......我希望这对其他人有帮助,我在寻找时无法找到满足我们需求的解决方案。

回答by skzac

well i've just resolved this error. just go to your project/website folder (not the published one). search web.config in the whole folder if it found more than once, you know which to delete. otherwise if only one web.config is found. make sure its has the rights to be Read. and the final problem if everything is fine, then make a new project in visual studio and remove all the components then add existing project by right clicking it, build,debug. Voila!!!

好吧,我刚刚解决了这个错误。只需转到您的项目/网站文件夹(不是已发布的文件夹)。在整个文件夹中搜索 web.config 如果发现不止一次,你知道删除哪个。否则,如果只找到一个 web.config。确保它有被读取的权利。最后一个问题,如果一切正常,然后在visual studio中创建一个新项目并删除所有组件,然后通过右键单击它,构建,调试来添加现有项目。瞧!!!