ChatGPT解决这个技术问题 Extra ChatGPT

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.

https://i.stack.imgur.com/rDKpi.jpg

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?

Instead of <add key="owin:AppStartup" value="false"></add> could you try <add key="owin:AutomaticAppStartup" value="false"></add> and see if that works? Also, some links to help: OWIN Startup Class Detection and Owin provide startup class in web.config (no automatic startup discovery)
That did the trick. Also thanks for the resources. My Gratitude @KeyurPATEL.
I think you are missing startup.cs file
Kurkula is absolutely right. You didn't install the ASP.net auth system just to throw it away on start up. You are absolutely missing the startup.cs file at the root of the project. Put this code in the file.------------- using Microsoft.Owin; using Owin; [assembly: OwinStartupAttribute(typeof(YOURPROJECT.Startup))] namespace YOURPROJECT { public partial class Startup { public void Configuration(IAppBuilder app) { ConfigureAuth(app); } } }

B
B--rian

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>

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


This is the solution, or at least this solution fixed my problem. Please mark an answer as a solution. This one should be at the top...
Thanks, This worked but can someone tell me what I'm loosing by making this setting value to false?
o
one_mile_run

I wanted to get rid of OWIN in the project:

Delete OWIN references and Nuget packages from project Clean & Rebuild project Run app

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

FIX:

Delete bin/ directory manually Rebuild project


lol - deleting bin and obj folders is always the fix for weird dependency errors
I had previously downloaded and tried the SignalR nuget, which in its turn had added the owin nuget. The packages were deleted, but I also had to delete the bin folder to get it working.
Came here after installing SignalR and aborting the endeavor. Thank you.
Easy and quick. Worked for me
uninstall owin package will help as well or removing all dlls having owin with them from references will help
r
robthedev

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

if you have a partial class "Startup" in your Startup.Auth file, create another partial Startup class in the root of your project. define an assembly owinstartup attribute pointing to that class create a "Configuration" method 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);
        }
    }
}

This worked for me, i realized that this happen when the project have a dot in it's name. So if the namespace its like "namespace ProjectNameSpace.ApiRest" then defining an assembly like in your example fix the problem.
V
Vishal

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


s
szdrnja

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);
        }
    }
}

For taking advantage of ASP.net Identity. This is the solution.
X
Xiao

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

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


R
Roshna Omer

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" />


A
Abhay

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


D
Debendra Dash

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

<appSettings>

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

W
Wilkoteq

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


M
Michael

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>


J
José Ignacio Becerra Becerra

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);
        }
    }
}

N
Narbs

I found a bug in Visual Studio 2019 V 16.10.2 that throws this error when you have a space in your project name whereby your namespace contains an underscore. To solve the issue, you have to explicitly set the startup class path in your web.config -> appSettings section:

<add key="owin:AppStartup" value="ABC_DEF.Startup"/>

G
Gabriel Girodo Domingos

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.


G
Gaurav soni

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


R
Reza Ghorbani

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


this is the real solution to the problem if you are using signalr package in your solution. than you for the answer.
n
nivs1978

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.


a
amit kadam

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>

f
funbrain9

It needs owin startup class for my case. Add new item > OWIN Startup Class > Name Startup.cs


D
Daniel Lobo

In my case, I had a main site that was with Forms Authentication. I needed to create an Web Application under that site that did a Single Sign On with a Identity Provider. The SSO application had to read a cookie that are supported by Owin, and convert it to the Form cookie to make compatible both the authentications. The problem was that it was installed under the main site the Owin Assemblies, and they, for some reason, even if they were not being used in the code or in the configuration files, were being called and trying to find the Startup class.

The solution was to uninstall all the Owin assemblies that were added by Nuget on the main site.


M
Marc Levesque

My issue had a much simpler fix.

I wasn't accessing the secure site. As soon as I pointed the browser to https://... it started working.


P
Psychonaut007

In my case I just deleted the bin and obj folder. Restarted the project, cleaned and build it.


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

Success story sharing

Want to stay one step ahead of the latest teleworks?

Subscribe Now