• .Net FW上线报错:The OwinStartup attribute discovered in assembly 'AppName'.


    阅文时长 | 2.32分钟 字数统计 | 3726.4字符
    主要内容 | 1、引言&背景 2、解决方案 3、声明与参考资料
    『.Net FW上线报错:The OwinStartup attribute discovered in assembly 'AppName'.』
    编写人 | SCscHero 编写时间 | 2022/2/18 PM8:20
    文章类型 | 系列 完成度 | 已完成
    座右铭 每一个伟大的事业,都有一个微不足道的开始。

    一、引言&背景   完成度:100%

    a) 应对问题

    近日上线遇到个问题,主要异常为:The OwinStartup attribute discovered in assembly 'AppName' referencing startup type 'AppName.Startup' conflicts with the attribute in assembly 'AppName' referencing startup type 'AppName.Startup' because they have the same FriendlyName ''.Remove or rename one of the attributes, or reference the desired type directly.看异常描述和一个OwinStartup的依赖项有关。

    详细异常信息如下:

    Server Error in '/' Application.
    The following errors occurred while attempting to load the app.
    - The OwinStartup attribute discovered in assembly 'SCOnlineWeb' referencing startup type 'SCOnlineWeb.Startup' conflicts with the attribute in assembly 'SCOnlineHosting' referencing startup type 'SCOnlineHosting.Startup' because they have the same FriendlyName ''. Remove or rename one of the attributes, or reference the desired type directly.
    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.
    - The OwinStartup attribute discovered in assembly 'SCOnlineWeb' referencing startup type 'SCOnlineWeb.Startup' conflicts with the attribute in assembly 'SCOnlineHosting' referencing startup type 'SCOnlineHosting.Startup' because they have the same FriendlyName ''. Remove or rename one of the attributes, or reference the desired type directly.
    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.
     - The OwinStartup attribute discovered in assembly 'SCOnlineWeb' referencing startup type 'SCOnlineWeb.Startup' conflicts with the attribute in assembly 'SCOnlineHosting' referencing startup type 'SCOnlineHosting.Startup' because they have the same FriendlyName ''. Remove or rename one of the attributes, or reference the desired type directly.
    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() +470
       Microsoft.Owin.Host.SystemWeb.OwinHttpModule.InitializeBlueprint() +37
       System.Threading.LazyInitializer.EnsureInitializedCore(T& target, Boolean& initialized, Object& syncLock, Func`1 valueFactory) +135
       Microsoft.Owin.Host.SystemWeb.OwinHttpModule.Init(HttpApplication context) +160
       System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers) +580
       System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context) +165
       System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context) +267
       System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext) +341
    
    [HttpException (0x80004005): The following errors occurred while attempting to load the app.
     - The OwinStartup attribute discovered in assembly 'SCOnlineWeb' referencing startup type 'SCOnlineWeb.Startup' conflicts with the attribute in assembly 'SCOnlineHosting' referencing startup type 'SCOnlineHosting.Startup' because they have the same FriendlyName ''. Remove or rename one of the attributes, or reference the desired type directly.
    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) +523
       System.Web.HttpRuntime.EnsureFirstRequestInit(HttpContext context) +107
       System.Web.HttpRuntime.ProcessRequestNotificationPrivate(IIS7WorkerRequest wr, HttpContext context) +688
    
    Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.7.3770.0
    
    

    b) 应用场景

    • .Net FW项目异常。

    二、解决方案   完成度:100%

    a) 分析检查

    检查是否有引用Microsoft.Owin的依赖,如有则需要配置了。

    using Microsoft.Owin;
    using Microsoft.Owin.Builder;
    using Owin;
    
    [assembly: OwinStartupAttribute(typeof(SCOnlineHosting.Startup))]
    namespace SCOnlineHosting
    {
        public partial class Startup {
            public void Configuration(AppBuilder app) {
                ConfigureAuth(app);
            }
        }
    }
    

    b) 配置web.config

    可在配置文件中添加appsetting:

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

    三、声明与参考资料   完成度:100%

    原创博文,未经许可请勿转载。

    如有帮助,欢迎点赞、收藏、关注。如有问题,请评论留言!如需与博主联系的,直接博客私信SCscHero即可。

  • 相关阅读:
    Docker 部署zookeeper3.4
    Redis 3.2 生产环境集群部署
    Prometheus入门到放弃(7)之redis_exporter部署
    Docker部署ELK 7.0.1集群之Kibana安装介绍
    Docker部署ELK 7.0.1集群之Logstash安装介绍
    Docker部署ELK 7.0.1集群之Elasticsearch安装介绍
    Node web 框架
    写一个简单的选择器( 方便小项目使用 )
    Node web 框架
    Node进阶
  • 原文地址:https://www.cnblogs.com/SCscHero/p/15913418.html
Copyright © 2020-2023  润新知