ChatGPT解决这个技术问题 Extra ChatGPT

OWIN Startup Class Missing

I'm getting this error as my project is not able to find the reference for OWIN startup class. I've even installed all the OWIN reference packages through Nuget still getting the same issue. I'm using Visual Studio 2012 and MVC4.

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.

Do you have a Startup.cs in the project?
Does your assembly contain an OwinStartupAttribute? Does your assembly a Startup or [AssemblyName].Startup class? Have you disabled OWIN startup discovery, by adding the appSetting owin:AutomaticAppStartup with a value of "false" in your web.config? Have you done one of these things and are wondering why it's not working? What is your question?
Thats the thing. Its not showing the OWIN Startup class when I try to add new Item in my project. I searched on google it says add OWIN References through nugets and I did the same. Still not getting the Class to add.

c
cracker

Create One Class With Name Startup this will help you..

public class Startup
{
   public void Configuration(IAppBuilder app)
   {
      app.MapSignalR();
   }
}

In addition to this, if your startup class is somehow not in your default name space, add a web config line to the <appSettings> area like: <add key="owin:AppStartup" value="[NameSpace].Startup" />
Nowaday, there are 3 ways to configurate owin: asp.net/aspnet/overview/owin-and-katana/…
In addition to @andrew-gray's comment, putting [assembly:OwinStartupAttribute(typeof(Identity_Test.Startup))] into AssemblyInfo.cs would work too.
you also need Microsoft.Owin.Host.SystemWeb package otherwise Startup is not called
We could also add this line just before the namespace of Startup class: [assembly: OwinStartup(typeof([YourStartupNamespaceName].Startup))]
H
Hüseyin Yağlı

In our project, we didn't need the OWIN functionality, so we removed all the owin references from the initial ASP.NET MVC template project. The problem occured after removing the OWIN startup class.

The problem was the extra owin dll's in my bin folder. When I deleted them, the problem was resolved. You should delete them by deleting the bin folder. Clean Solution does not delete these dlls.

Somehow, IIS still executes the OWIN dll's when they are in the bin folder.


I had this problem too and also had to make sure the References didn't reference any OWIN DLL's.
Same issue and same solution. However in my case I had one branch of code with Signalr and one without. When switching branches the Signalr dlls remained even after a Clean. I needed to manually delete them.
Just a note to say this literally means the bin folder not just using "Clean Solution" from Visual Studio which in my case was deleting most DLLs but not all.
Something that worked for me, is after deleting OWIN references and it still not working properly was adding <add key="owin:AutomaticAppStartup" value="false"/> as an appSetting. Just some advice to people trying this and it still not succeeding.
For people who this didn't work for, make sure that even after you have deleted the bin folders that you go into the project references and remove references to the Owin dll's. In my case I deleted the bin folders but forgot I still had the (unused) references sitting in the .csproj file.
T
Timuçin

On Visual Studio 2013 RC2, there is a template for this. Just add it to App_Start folder.

https://i.stack.imgur.com/fN0lO.png

The template produces such a class:

using System;
using System.Threading.Tasks;
using Microsoft.Owin;
using Owin;

[assembly: OwinStartup(typeof(WebApiOsp.App_Start.Startup))]

namespace WebApiOsp.App_Start
{
    public class Startup
    {
        public void Configuration(IAppBuilder app)
        {
            // For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=316888
        }
    }
}

VS2015 needed this as well
This did it for me - I created the Startup.cs file and populated it correctly but missed that it needed to be in the App_Start folder. Ran fine on my dev machine, but once published was erroring out. Thanks!
Remember to add app.MapSignalR(); in Configuration(IAppBuilder app), else 404 is returned when calling [YourSite]/signalr
Thanks for the screenshot. That really helps.
For the benefit of posterity, I recently got this error while trying to implement the Dancing Goat account related features into a new Kentico MVC project created under Kentico 12SP. After getting the correct Owin packages installed the error in this post came up. After following the recommendation of this post it was fixed. TYVM :)
Y
Yonatan Ayalon

If you don't want to use the OWIN startup, this is what you should add to your web.config file:

Under AppSettings add the following line:

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

This is how it should look like in your web.config:

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

This is actually one of the complete answers. If you're not very into web.config settings, it's hard to figure that you should add a key and a value in the xml file
C
Christian Phillips

Have a look for the Startup.cs file, you might be missing one of these. This file is the entry point for OWIN, so it sounds like this is missing. Take a look at OWIN Startup class here to understand whats going on.

As your error specifies, you can disable this in the web.config by doing the following...

To disable OWIN startup discovery, add the appSetting owin:AutomaticAppStartup with a value of "false" in your web.config


I added <add key="owin:AutomaticAppStartup" value="false" /> to the <appSettings> group and the Startup.cs was no longer needed.
@webworm, I mention that above.
@christiandev what exactly will <add key="owin:AutomaticAppStartup" value="false" /> do? Will it disable any functionality? Do we need to start the app later to be able to use any OWIN functionality?
S
Slaters

First you have to create your startup file and after you must specify the locale of this file in web.config, inside appSettings tag with this line:

<add key="owin:AppStartup" value="[NameSpace].Startup"/>

It solved my problem.


T
TCC

I had this problem, understand this isn't what was wrong in the OP's case, but in my case I did have a Startup class, it just wasn't finding it by default.

My problem was the I had spaces in my Assembly Name, and hence the default namespace was different from assembly name, hence the namespace for the startup class was different than the assembly name.

As the error suggests, by convention it looks for [Assembly Name].Startup for the class... so be sure the namespace for your Startup class is the same as the Assembly name. Fixed the problem for me.


I had a similar problem. My project name had a '-' hyphen in it, which was converted to underscore by VS, so the namespace and the startup class were essentially different.
C
Community

I tried most of the recommended fixes here, and still couldn't avoid the error message. I finally performed a combination of a few recommended solutions:

Added this entry to the top of the AppSettings section of my web.config: Expanded the References node of my project and deleted everything that contained the string OWIN. (I felt safe doing so since my organization is not (and won't be) an active OWIN provider in the future)

I then clicked Run and my homepage loaded right up.


U
Unlearnd

In my case, I had renamed the project and changed it's folder structure. I found that updating the RootNameSpace and AssemblyName in the .csproj file where the error was being thrown resolved the error. If you have modified paths of your project I'd recommend checking this as well.

<RootNamespace>Company.Product.WebAPI</RootNamespace>
<AssemblyName>Company.Product.WebAPI</AssemblyName>

Holy cow kudos to you bro, was stuck on it like forever and found no solution until I read this, the AssemblyName wasn't updated after I changed it manually. Now it works! Thank you so much!
m
mcarter

It is also possible to get this exception (even when you have a correctly configured startup class) if running through IIS Express and your virtual directory is not configured correctly.

When I encountered this issue, the resolution was simply to press the 'Create Virtual Directory' button in the 'Web' tab of project properties (Using Visual Studio 2013)


G
Gellie Ann

My case? I had startup file, but it is excluded in the project. I just included it and the error left.


c
carraua

Are you really trying to add OWIN to your project or is this something unexpected?

In case you want to add OWIN, adding a Startup class is the way to go. In case you don't need any reference to Owin: delete Owin.dll from your /bin folder. Owin.dll is the one trying to identify the Startup class.


D
Diceyus

This could be faced in Visual Studio 2015 as well when you use the Azure AD with a MVC project. Here it create the startup file as Startup.Auth.cs in App_Start folder but it will be missing the

[assembly: OwinStartup(typeof(MyWebApp.Startup))]

So add it and you should be good to go. This goes before the namespace start.


C
Community

While I can't fully explain why this solved the issue for me, I ran into a problem like this after I changed my API project to build to separate \debug and \release folders. Once I reverted that change back to build to a single \bin folder things started working.

I wrote up my experience here: Can't get the OWIN Startup class to run in IIS Express after renaming ASP.NET project file


O
Owen Pauling

I ran into this problem after experimenting with SignalR and then removing it from the project. To resolve I had to delete the contents of the bin folder for the site on the remote server and then publish again.


I
Ian

Just check that your packages.config file is checked in (when excluded, there will be a red no-entry symbol shown in the explorer). For some bizarre reason mine was excluded and caused this issue.


a
alikuli

I kept getting the same error when I started my project using the Browser Link Dashboard in VS2013. But, when I ran my project in debug mode, it would work. I could not figure out why and how to get the Browser Link Dashboard working. I checked the startup file, it was fine, added the appSetting line as described in some of the answers "", but nothing worked.

Apparently, what I was doing wrong was clicking on the WRONG link in the Browser Dashboard. All the Solutions projects links show in the Browser Dashboard, but only the startup projects link works. You need to click on the link of the startup project.

Example: I have 2 projects, both show in the Browser Dashboard, but only the one marked as the start up project will work (shows as bold in the Solution Explorer.) I thought this may help someone do the obvious, it cost me 2 days to stumble on to the obvious.


P
PersyJack

I had this problem when I got the latest on TFS while other projects were open in multiple instances of VS. I already have all the fixes above. Reopening VS fixed the problem.


K
Kurkula

In my case I logged into ftp server. Took backup of current files on ftp server. Delete all files manually from ftp server. Clean solution, redeployed the code. It worked.


关注公众号,不定期副业成功案例分享
Follow WeChat

Success story sharing

Want to stay one step ahead of the latest teleworks?

Subscribe Now