Asp.net-Mvc
重命名 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。
我似乎無法找到任何具有舊名稱的地方,但是它提到的錯誤中存在差異。
這個問題我已經遇到過幾次了,所以我會寫下我遵循的程序作為對自己的提醒:
- 將所有舊解決方案名稱替換為新名稱。
- 導航到每個項目下的屬性,並將****程序集名稱和預設命名空間欄位更改為新的解決方案名稱。
- 轉到解決方案文件夾並使用新的解決方案名稱重命名所有項目文件夾。
- 刪除bin和obj文件夾下的所有文件。
- 解決方案將無法載入項目。刪除所有項目並再次添加它們。
- 重新建構項目。