[c#] No assembly found containing an OwinStartupAttribute Error

This error

The following errors occurred while attempting to load the app. - No assembly found containing an OwinStartupAttribute. - The given type or method 'false' was not found. Try specifying the Assembly. 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.

appears on my screen on the most face burningly ugly error page ever created in history.

enter image description here

Ive tried to follow the instructions on the page by inserting the owin:AutomaticAppStartup in the config.

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

this did not fix the problem. Any suggestions?

This question is related to c# web-config owin .net-assembly

The answer is


I deleted all DLLs from the branch which wasn't working, then I copied all DDls from my branch which was working to my branch wich wasn't. This solved the issue.


Check if you have the Startup class created in your project. This is an example:

using Microsoft.Owin;
using Owin;

[assembly: OwinStartupAttribute(typeof({project_name}.Startup))]

namespace AuctionPortal
{
    public partial class Startup
    {
        public void Configuration(IAppBuilder app)
        {
            ConfigureAuth(app);
        }
    }
}

if you want to use signalr you haveto add startup.cs Class in your project

Right Click In You Project Then Add New Item And Select OWIN Startup Class

then inside Configuration Method Add Code Below

app.MapSignalR();

I Hope it will be useful for you


I got this error because there was an extra white space in the code

Instead of

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

It was

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


just replacing

        using (WebApp.Start(url))

with

        using (WebApp.Start<Startup>(url))

solved my problem. The class named Startup was already implemented. as mentioned above by @robthedev


I was missing the attribute:

[assembly: OwinStartupAttribute(typeof(projectname.Startup))]

Which specifies the startup class. More details: https://docs.microsoft.com/en-us/aspnet/aspnet/overview/owin-and-katana/owin-startup-class-detection


Add below code to your web.config file then run the project...

    <runtime>
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
    <dependentAssembly>
    <assemblyIdentity name="Microsoft.Owin.Security" publicKeyToken="31bf3856ad364e35"/>
    <bindingRedirect oldVersion="1.0.0.0-3.0.1.0" newVersion="3.0.1.0"/>
    </dependentAssembly>
    <dependentAssembly>
    <assemblyIdentity name="Microsoft.Owin.Security.OAuth" publicKeyToken="31bf3856ad364e35"/>
    <bindingRedirect oldVersion="1.0.0.0-3.0.1.0" newVersion="3.0.1.0"/>
    </dependentAssembly>
    <dependentAssembly>
    <assemblyIdentity name="Microsoft.Owin.Security.Cookies" publicKeyToken="31bf3856ad364e35"/>
    <bindingRedirect oldVersion="1.0.0.0-3.0.1.0" newVersion="3.0.1.0"/>
    </dependentAssembly>
    <dependentAssembly>
    <assemblyIdentity name="Microsoft.Owin" publicKeyToken="31bf3856ad364e35"/>
    <bindingRedirect oldVersion="1.0.0.0-3.0.1.0" newVersion="3.0.1.0"/>
    </dependentAssembly>
    </runtime>

I know this post is old but just in case someone is looking for the same error, try adding

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

after the tag <appSettings>

and if afterwards the next error show up:

HTTP Error 401.0 - Unauthorized error message

add the next code after the tag <system.web> it can be at the beginning

<authentication mode="Forms"> <forms loginUrl="~/YourFolderName/yourFileName" timeout="1" /> </authentication>

In my case is:

<authentication mode="Forms"> <forms loginUrl="~/Login/Index" timeout="1" /> </authentication>


If deploying to Azure and you get this error. Simply delete all files on the site (backup any web.config, appsettings.json or whatver you do not want to loose) and deploy again. There are some left over dll files that should not be on the site, that makes the Azure portal think it needs to use OWIN.


Add class Startup.cs to root of project with next code:

using Microsoft.Owin;
using Owin;

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

For those who do want owin to start, <add key="owin:AutomaticAppStartup" value="false" /> won't work, but the following worked for me.

  1. if you have a partial class "Startup" in your Startup.Auth file, create another partial Startup class in the root of your project.

  2. define an assembly owinstartup attribute pointing to that class

  3. create a "Configuration" method

  4. rebuild your application

You could also create the "Configuration" method, and add the assembly attribute to the Startup.Auth, but doing it this way allows you to keep your Startup class separated by leveraging C# class definition splitting. Read more here: https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/partial-classes-and-methods

This is what my Startup.cs file looked like:

using Microsoft.Owin;
using Owin;

[assembly: OwinStartupAttribute(typeof(ProjectNameSpace.Startup))]

namespace ProjectNameSpace
{
    public partial class Startup
    {
        public void Configuration(IAppBuilder app)
        {
            ConfigureAuth(app);
        }
    }
}

just paste this code <add key="owin:AutomaticAppStartup" value="false" /> in Web.config Not In web.config there is two webconfig so be sure that it will been paste in Web.Config


I wanted to get rid of OWIN in the project:

  1. Delete OWIN references and Nuget packages from project
  2. Clean & Rebuild project
  3. Run app

Then I got OWIN error. These steps didn't work, because OWIN.dll was still in bin/ directory.

FIX:

  1. Delete bin/ directory manually
  2. Rebuild project

Add the following key in Web.config will remove the code

<appSettings>

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

you may not have Configuration method in the class you mentioned in

<appSettings>
<add key="owin:AppStartup" value="WebApplication1.App_Start.Startup"/>


Add this code in web.config under the <configuration> tag as shown in image below. Your error should then be gone.

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

Check Image Below


Check you have the correct startup project selected. I had a web api project as startup. That generated this error.


Examples related to c#

How can I convert this one line of ActionScript to C#? Microsoft Advertising SDK doesn't deliverer ads How to use a global array in C#? How to correctly write async method? C# - insert values from file into two arrays Uploading into folder in FTP? Are these methods thread safe? dotnet ef not found in .NET Core 3 HTTP Error 500.30 - ANCM In-Process Start Failure Best way to "push" into C# array

Examples related to web-config

No assembly found containing an OwinStartupAttribute Error IIS Config Error - This configuration section cannot be used at this path How to enable GZIP compression in IIS 7.5 how to set start page in webconfig file in asp.net c# Authentication issue when debugging in VS2013 - iis express Forms authentication timeout vs sessionState timeout Specified argument was out of the range of valid values. Parameter name: site Access-control-allow-origin with multiple domains "An exception occurred while processing your request. Additionally, another exception occurred while executing the custom error page..." ASP.NET: HTTP Error 500.19 – Internal Server Error 0x8007000d

Examples related to owin

No assembly found containing an OwinStartupAttribute Error Adding ASP.NET MVC5 Identity Authentication to an existing project Getting "error": "unsupported_grant_type" when trying to get a JWT by calling an OWIN OAuth secured Web Api via Postman OWIN Security - How to Implement OAuth2 Refresh Tokens OwinStartup not firing OWIN Startup Class Missing

Examples related to .net-assembly

No assembly found containing an OwinStartupAttribute Error Could not load file or assembly 'Newtonsoft.Json' or one of its dependencies. Manifest definition does not match the assembly reference Could not load file or assembly or one of its dependencies. Access is denied. The issue is random, but after it happens once, it continues System.IO.FileNotFoundException: Could not load file or assembly 'X' or one of its dependencies when deploying the application How to view the Folder and Files in GAC? How can I get the executing assembly version? How do I find the PublicKeyToken for a particular dll?