ASP.Net MVC – resolved error – No assembly found containing an OwinStartupAttribute No assembly found containing a Startup or [AssemblyName].Startup class.

Hi All,
Today new issue and solution 🙂
Background: I was developing MVC web application and I want to call the Microsoft Graph API. So I started from scratch – created new MVC application, and using NuGet package manager installed following required packages
- Install-Package Microsoft.Owin.Host.SystemWeb
- Install-Package Microsoft.Owin.Security.OpenIdConnect
- Install-Package Microsoft.Owin.Security.OpenIdConnect
- Install-Package Microsoft.Owin.Security.Cookies
- Install-Package Microsoft.Identity.Client -Version 4.3.1
- Install-Package Microsoft.Graph -Version 1.17.0
Those packages are installed successfully. Then I executed/run the application, getting following error as
![Asp.Net MVC - Error - No assembly found containing an OwinStartupAttribute No assembly found containing a Startup or [AssemblyName].Startup class](https://i1.wp.com/knowledge-junction.com/wp-content/uploads/2019/09/Fig1_MVCApp.png?fit=690%2C388&ssl=1)
Fig1: Asp.Net MVC – Error – No assembly found containing an OwinStartupAttribute No assembly found containing a Startup or [AssemblyName].Startup class
Server Error in ‘/’ Application.
The following errors occurred while attempting to load the app.
– No assembly found containing an OwinStartupAttribute.
– No assembly found containing a Startup or [AssemblyName].Startup class.
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.
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.EntryPointNotFoundException: The following errors occurred while attempting to load the app.
– No assembly found containing an OwinStartupAttribute.
– No assembly found containing a Startup or [AssemblyName].Startup class.
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.
Source Error:An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Stack Trace: [EntryPointNotFoundException: The following errors occurred while attempting to load the app.
– No assembly found containing an OwinStartupAttribute.
– No assembly found containing a Startup or [AssemblyName].Startup class.
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() +357
Microsoft.Owin.Host.SystemWeb.OwinHttpModule.InitializeBlueprint() +28
System.Threading.LazyInitializer.EnsureInitializedCore(T& target, Boolean& initialized, Object& syncLock, Func`1 valueFactory) +115
Microsoft.Owin.Host.SystemWeb.OwinHttpModule.Init(HttpApplication context) +106
System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +536
System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +172
System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +336
System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +296
[HttpException (0x80004005): The following errors occurred while attempting to load the app.
– No assembly found containing an OwinStartupAttribute.
– No assembly found containing a Startup or [AssemblyName].Startup class.
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) +9984648
System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +101
System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +254
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.6.1715.0
Solution:
There are multiple options to solve this issue. If we notice, options are mentioned in stack trace itself as
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.
Option 1: So if we update web.config file, add new key “<add key=”owin:AutomaticAppStartup” value=”false” />” in <appSettings> in <configuration> section as
Option 2: Add default OWIN startup class as
public class Startup
{
public void Configuration(IAppBuilder app)
{
// For more information on how to configure your application,
//visit https://go.microsoft.com/fwlink/?LinkID=316888
}
}
Here for our solution we have used second option.
Details: As I am cloud (M365 / SharePoint) guy, I was not much aware / understand the exact issue so thought to go into depth.
What is OWIN?
OWIN = Open Web Interface for .Net
Before OWIN Microsoft Asp.Net framework lacking portability, molecularity and scalability. Means there were still dependencies between Microsoft Asp.Net application and hosting servers. So OWIN come up with the concept like how the dependency between Asp.Net application and hosting servers can be removed.
OWIN removes Asp.Net application dependency on System.Web assembly which is heavily depends on IIS (web server). Before OWIN its not possible to run the Asp.Net application on different web server than IIS. OWIN decouple the relationship between ASP.NET application and IIS by defining standard interface.
The OWIN Framework: The Owin Framework is a set of NuGet packages that can be used to build powerful and extremely scalable applications and services that are delivered over Http.
The Owin Framework builds on OWIN, developed by Microsoft to isolate web applications from the hosting platform
This means that applications based on OWIN can run on Apache, IIS, self-host (ie run as a standalone application that listens for Http requests directly) or any other hosting platform.
I hope this will clear the concept why OWIN is required, basically here to execute application as standalone application means self-hosting 🙂
References:
Thanks for reading 🙂
Keep reading, share your thoughts, experiences. Feel free to contact us to discuss more.
If you have any suggestion / feedback / doubt, you are most welcome.
Stay tuned on Knowledge-Junction, will come up with more such articles.
You must log in to post a comment.