简体   繁体   English

类型'Startup'已经定义了一个名为'Configuration'的成员,它具有相同的参数类型

[英]Type 'Startup' already defines a member called 'Configuration' with the same parameter types

I have this on my startup.cs 我在我的startup.cs上有这个

using Microsoft.Owin;
using Owin;

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

and I have this Startup.Auth.cs 我有这个Startup.Auth.cs

using System;
using Microsoft.Owin;
using Microsoft.Owin.Security.Cookies;
using Owin;

namespace xx.yy
{
    public static class xxAuthentication
    {
        public const String ApplicationCookie = "xxAuthenticationType";
    }

    public partial class Startup
    {
        public void ConfigureAuth(IAppBuilder app)
        {
            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = xxAuthentication.ApplicationCookie,
                LoginPath = new PathString("/Login"),
                Provider = new CookieAuthenticationProvider(),
                CookieName = "ComisionesCookie",
                CookieHttpOnly = true,
                ExpireTimeSpan = TimeSpan.FromHours(12), // adjust to your needs
            });
        }
    }
}

Howevver it does not compile with this error: 但是它不能用这个错误编译:

图片

I use the code from this page http://tech.trailmax.info/2016/03/using-owin-and-active-directory-to-authenticate-users-in-asp-net-mvc-5-application/ 我使用此页面中的代码http://tech.trailmax.info/2016/03/using-owin-and-active-directory-to-authenticate-users-in-asp-net-mvc-5-application/

Easy, but hard to find, the problem is another developer created a startup.cs file with same signature in a different folder in the project structure. 容易但很难找到,问题是另一个开发人员在项目结构的不同文件夹中创建了一个具有相同签名的startup.cs文件。 Will leave evidence here because it might be useful for another developer 这里会留下证据,因为它可能对其他开发人员有用

You could have to constructors members in Startup class like this: 您可能必须在Startup类中构造成员,如下所示:

public class Startup {

    public Startup(IConfiguration _configuration){
        this._configuration = _configuration;
    }

    private IConfiguration _configuration{ 
        get; 
    }

    public Startup(IConfiguration configuration){
        // Expose the injected instance locally so we populate our settings instance
        _configuration = configuration;
    }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 类型“Type”已经定义了一个名为“Equals”的成员,在 Equals(object) 上具有相同的参数类型 - Type 'Type' already defines a member called 'Equals' with the same parameter types on Equals(object) 已经使用相同的参数类型定义了一个名为“InitializeComponent”的成员 - Already defines a member called 'InitializeComponent' with the same parameter types 错误 - 已经使用相同的参数类型定义了一个名为“InitializeComponent”的成员 - Error - already defines a member called 'InitializeComponent' with the same parameter types “'Form1' 已经定义了一个名为 '.ctor' 的成员,具有相同的参数类型” - "'Form1' already defines a member called '.ctor' with the same parameter types " Web Api已经使用相同的参数类型定义了一个名为“ Get”的成员 - Web Api already defines a member called 'Get' with the same parameter types 错误已使用相同的参数类型定义了一个名为“索引”的成员 - Error already defines a member called 'Index' with the same parameter types 已经定义了一个使用相同参数类型调用的成员 c# - already defines a member called with the same parameter types c# C#错误:类型'x'已经定义了一个名为'y'的成员,它具有相同的参数类型 - C# error: Type 'x' already defines a member called 'y' with the same parameter types 错误1类型“ Pay”已经使用相同的参数类型定义了一个名为“ ComputePay”的成员 - Error 1 Type 'Pay' already defines a member called 'ComputePay' with the same parameter types 类型 'Gap66.Web.PaymentGateway.SagepayForm.PaymentRequest' 已经定义了一个名为 'this' 的成员,具有相同的参数类型 - Type 'Gap66.Web.PaymentGateway.SagepayForm.PaymentRequest' already defines a member called 'this' with the same parameter types
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM