重命名 ASP.NET MVC 项目时出错

我复制了以前的一个项目,并将其重新命名。一旦我成功地重命名了所有的名称空间,并且正确地构建了它。在运行应用程序时,我得到了以下错误:

The following errors occurred while attempting to load the app.
- The OwinStartup attribute discovered in assembly 'User Manager Interface' referencing    startup type 'User_Manager_Interface.Startup' conflicts with the attribute in assembly   'Service Monitor Web Interface' referencing startup type  'Service_Monitor_Web_Interface.Startup' because they have the same FriendlyName ''. Remove or   rename one of the attributes, or reference the desired type directly.
To disable OWIN startup discovery, add the appSetting owin:AutomaticAppStartup with a value of "false" in your web.config.
To specify the OWIN startup Assembly, Class, or Method, add the appSetting owin:AppStartup with the fully qualified startup class or configuration method name in your web.config.

我已经算出,如果我注释掉下面的第一行,那么错误就消失了。

//[assembly: OwinStartupAttribute(typeof(Service_Monitor_Web_Interface.Startup))]
namespace Service_Monitor_Web_Interface
{
public partial class Startup
{
public void Configuration(IAppBuilder app)
{
ConfigureAuth(app);
}
}
}

我将解决方案从 User _ Manager _ Interface 重命名为 Service _ Monitor _ Web _ Interface。

我似乎找不到任何地方与旧名称,无论在错误它提到它。

39475 次浏览

在重命名解决方案的程序集之后,我遇到了同样的问题。

通过确保 OwinStartupAttribute 引用我的新程序集名称,我解决了这个问题。

接下来是删除在 bin 文件夹中找到的旧程序集。

这个问题我已经遇到过好几次了,所以我会把我遵循的步骤写下来,作为对自己的提醒:

  1. 用新的名称替换所有旧的解决方案名称。
  2. 导航到每个项目下的 物业,并将 程序集名称默认命名空间字段更改为新的解决方案名称。
  3. 转到解决方案文件夹并用新的解决方案名称重命名所有项目文件夹。
  4. 删除 垃圾箱对不起文件夹下的所有文件。
  5. 解决方案将无法加载项目。请删除所有项目并再次添加它们。
  6. 重建项目。

我没有重命名我的解决方案,但我确实遇到了这个问题。我找不到一个解决方案张贴在任何地方。我在同一台服务器上有两个独立的项目和一个 owin 启动类。我只是按照异常消息中的建议,给每个用户一个不同的“ Friendly Name”,它就解决了这个问题。我找到一篇关于这个的好文章:

欧文创业班

要重命名它,只需在 OwinStartup Like 上添加一个字符串,如下所示:

[汇编: OwinStartup (“ ProductionConfiguration”,typeof (StartupDemo. ProductionStartup2))]

如果在同一 bin 文件夹中有两个包含 OwinStartup 类的程序集,则会发生此问题。通常,对于同一个 Web 应用程序,不应该有两个 OwinStartup 类。

您可以通过检查 bin 文件夹来解决这个问题。如果在重命名之后,旧名称的程序集仍然保留在 bin 文件夹中,则会得到此错误。要解决此问题,请删除 bin 文件夹中的所有内容。

在 web 配置应用程序中添加以下标记

<appSettings>
<add key="owin:AutomaticAppStartup" value="false" />
</appSettings>

我有两个 ASP.NETMVC5项目,Project1和 Project2。

问题是两个项目的 DLL 位于同一个 bin 文件夹中,而且都使用了 Owin 中间件。这意味着 Project1.dll 和 Project2.dll 存在于 Project2的同一 bin 文件夹中。

因为我在每个项目中只需要其中的一个,所以我只需要删除 Project2 bin 文件夹中未使用的 Project1.dll。