2021年7月7日 星期三

[研究][ASP.NET] No assembly found containing an OwinStartupAttribute

[研究][ASP.NET] No assembly found containing an OwinStartupAttribute

2021-07-06


'/' 應用程式中發生伺服器錯誤。

The following errors occurred while attempting to load the app.
- No assembly found containing an OwinStartupAttribute.
- No 'Configuration' method was found in class 'WebApplication1Admin.Startup, 
WebApplication1Admin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.

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.

描述: 在執行目前 Web 要求的過程中發生未處理的例外狀況。請檢閱堆疊追蹤以取得錯誤的詳細資訊,以及在程式碼中產生的位置。

例外狀況詳細資訊: System.EntryPointNotFoundException: The following errors occurred while attempting to load the app.
- No assembly found containing an OwinStartupAttribute.
- No 'Configuration' method was found in class 'WebApplication1Admin.Startup, WebApplication1Admin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.
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.

原始程式錯誤:

在執行目前 Web 要求期間,產生未處理的例外狀況。如需有關例外狀況來源與位置的資訊,可以使用下列的例外狀況堆疊追蹤取得。


堆疊追蹤:

[EntryPointNotFoundException: The following errors occurred while attempting to load the app.
 - No assembly found containing an OwinStartupAttribute.
 - No 'Configuration' method was found in class 'WebApplication1Admin.Startup, WebApplication1Admin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.
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.]
   Microsoft.Owin.Host.SystemWeb.OwinBuilder.GetAppStartup() +480
   Microsoft.Owin.Host.SystemWeb.OwinHttpModule.InitializeBlueprint() +37
   System.Threading.LazyInitializer.EnsureInitializedCore(T& target, Boolean& initialized, Object& syncLock, Func`1 valueFactory) +139
   Microsoft.Owin.Host.SystemWeb.OwinHttpModule.Init(HttpApplication context) +160
   System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +587
   System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +173
   System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +255
   System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +347

[HttpException (0x80004005): The following errors occurred while attempting to load the app.
 - No assembly found containing an OwinStartupAttribute.
 - No 'Configuration' method was found in class 'WebApplication1Admin.Startup, WebApplication1Admin, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.
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.] System.Web.HttpRuntime.FirstRequestInit(HttpContext context) +552 System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +122 System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +737



版本資訊: Microsoft .NET Framework 版本:4.0.30319; ASP.NET 版本:4.8.4330.0

********************************************************************************

解決

Web.Config 加上

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

或網站根目錄放一個 Startup.cs


using Microsoft.Owin;
using Owin;

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

(完)

沒有留言:

張貼留言