Answered by:
Severity_Code_Description_Project_File_Line_Suppression State Error_CS0111_Type 'EmailService' already defines a member called 'SendAsync' with the same parameter types _

Question
-
User-605499000 posted
Using Identity Config I am getting the above error for email service, SendAsyn, SmsService.
Also getting this message on Identity Config.
Severity Code Description Project File Line Suppression State
Eerror CS0101 The namespace 'Jen19' already contains a definition for 'ApplicationUserManager' and
Severity Code Description Project File Line Suppression State
Error CS0111 Type 'ApplicationUserManager' already defines a member called 'Create' with the same parameter typesBelow is the code and I have put an * next to the line. I have been using wingtiptoys program to write my program.
using System;
using System.Security.Claims;
using System.Threading.Tasks;
using Microsoft.AspNet.Identity;
using Microsoft.AspNet.Identity.EntityFramework;
using Microsoft.AspNet.Identity.Owin;
using Microsoft.Owin;
using Microsoft.Owin.Security;
using Jen19.Models;namespace Jen19
{
public class EmailService : IIdentityMessageService **
{
public Task SendAsync(IdentityMessage message) **
{
// Plug in your email service here to send an email.
return Task.FromResult(0);
}
}public class SmsService : IIdentityMessageService **
{
public Task SendAsync(IdentityMessage message) **
{
// Plug in your SMS service here to send a text message.
return Task.FromResult(0);
}
}// Configure the application user manager used in this application. UserManager is defined in ASP.NET Identity and is used by the application.
public class ApplicationUserManager : UserManager<ApplicationUser>
{
public ApplicationUserManager(IUserStore<ApplicationUser> store)
: base(store)
{
}public static ApplicationUserManager Create(IdentityFactoryOptions<ApplicationUserManager> options, IOwinContext context)
{
var manager = new ApplicationUserManager(new UserStore<ApplicationUser>(context.Get<ApplicationDbContext>()));
// Configure validation logic for usernames
manager.UserValidator = new UserValidator<ApplicationUser>(manager)
{
AllowOnlyAlphanumericUserNames = false,
RequireUniqueEmail = true
};// Configure validation logic for passwords
manager.PasswordValidator = new PasswordValidator
{
RequiredLength = 6,
RequireNonLetterOrDigit = true,
RequireDigit = true,
RequireLowercase = true,
RequireUppercase = true,
};// Register two factor authentication providers. This application uses Phone and Emails as a step of receiving a code for verifying the user
// You can write your own provider and plug it in here.
manager.RegisterTwoFactorProvider("Phone Code", new PhoneNumberTokenProvider<ApplicationUser>
{
MessageFormat = "Your security code is {0}"
});
manager.RegisterTwoFactorProvider("Email Code", new EmailTokenProvider<ApplicationUser>
{
Subject = "Security Code",
BodyFormat = "Your security code is {0}"
});// Configure user lockout defaults
manager.UserLockoutEnabledByDefault = true;
manager.DefaultAccountLockoutTimeSpan = TimeSpan.FromMinutes(5);
manager.MaxFailedAccessAttemptsBeforeLockout = 5;manager.EmailService = new EmailService();
manager.SmsService = new SmsService();
var dataProtectionProvider = options.DataProtectionProvider;
if (dataProtectionProvider != null)
{
manager.UserTokenProvider = new DataProtectorTokenProvider<ApplicationUser>(dataProtectionProvider.Create("ASP.NET Identity")); **
}
return manager;
}
}public class ApplicationSignInManager : SignInManager<ApplicationUser, string>**
{
public ApplicationSignInManager(ApplicationUserManager userManager, IAuthenticationManager authenticationManager) : **
base(userManager, authenticationManager)
{ }public override Task<ClaimsIdentity> CreateUserIdentityAsync(ApplicationUser user) **
{
return user.GenerateUserIdentityAsync((ApplicationUserManager)UserManager);**
}public static ApplicationSignInManager Create(IdentityFactoryOptions<ApplicationSignInManager> options, IOwinContext context)
{
return new ApplicationSignInManager(context.GetUserManager<ApplicationUserManager>(), context.Authentication);
}
}
}Can I not use this file. The login and register files are okay.
Thanks,
jen
Thursday, June 27, 2019 8:47 PM
Answers
-
User-605499000 posted
Thank you for getting back to me so fast. I didn't have another identity config just the one in the App.start. but I just changed my namespace to
namespace Jen19.App_Start and all the errors went away. Wingtips just uses namespace WingtipsToys but It didn't work for me.
I will mark this a resolved and thanks again for your help.
Jen
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Friday, June 28, 2019 6:23 PM
All replies
-
User665608656 posted
Hi bumples,
Can I not use this file. TYes,you don't need to use this file.
According to your description, the wingtiptoys program you have used already contains a cs file named IdentityConfig.
And the IdentityConfig.cs file contains the EmailService class you created, which is why this error occurs.
Here is the picture about what cs files your wingtiptoys program already contains:
Best Regards,
YongQing.
Friday, June 28, 2019 9:14 AM -
User-605499000 posted
Thank you for getting back to me so fast. I didn't have another identity config just the one in the App.start. but I just changed my namespace to
namespace Jen19.App_Start and all the errors went away. Wingtips just uses namespace WingtipsToys but It didn't work for me.
I will mark this a resolved and thanks again for your help.
Jen
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Friday, June 28, 2019 6:23 PM