I had an error of Email in line " dynamic email = new Email("ChngPasswordEmail");" which say's The type or Namespace name "Email" could not be found Pin
-
public void ResetPassword(UserModel model, string Name)
{using (var db = new sortit\_internEntities()) { string emailAddress = (from info in db.users where info.name.Equals(model.Name) select info.email).Single(); if (!string.IsNullOrEmpty(emailAddress)) { string confirmationToken = WebSecurity.GeneratePasswordResetToken(model.Name); dynamic email = new Email("ChngPasswordEmail"); email.To = emailAddress; email.UserName = model.Name; email.ConfirmationToken = confirmationToken; email.Send(); } } }
for resetting password for login and yes I am new to MVC, this code is in business layer of MVC for kind Information
-
public void ResetPassword(UserModel model, string Name)
{using (var db = new sortit\_internEntities()) { string emailAddress = (from info in db.users where info.name.Equals(model.Name) select info.email).Single(); if (!string.IsNullOrEmpty(emailAddress)) { string confirmationToken = WebSecurity.GeneratePasswordResetToken(model.Name); dynamic email = new Email("ChngPasswordEmail"); email.To = emailAddress; email.UserName = model.Name; email.ConfirmationToken = confirmationToken; email.Send(); } } }
for resetting password for login and yes I am new to MVC, this code is in business layer of MVC for kind Information
-
public void ResetPassword(UserModel model, string Name)
{using (var db = new sortit\_internEntities()) { string emailAddress = (from info in db.users where info.name.Equals(model.Name) select info.email).Single(); if (!string.IsNullOrEmpty(emailAddress)) { string confirmationToken = WebSecurity.GeneratePasswordResetToken(model.Name); dynamic email = new Email("ChngPasswordEmail"); email.To = emailAddress; email.UserName = model.Name; email.ConfirmationToken = confirmationToken; email.Send(); } } }
for resetting password for login and yes I am new to MVC, this code is in business layer of MVC for kind Information
Look at the error message:
The type or Namespace name "Email" could not be found
It's pretty explicit! The compiler does not know what the
Email
class is: it hasn't got one for you to use. Either you haven't added a reference to the assembly containing the class to your project, and ausing
statement at the top of the file to the namespace the class is in; or just theusing
statement is missing; or you do not have a class calledEmail
at all. Hover the mouse over the word "Email" and a little blue bar will appear at the beginning. Hover the mouse over that and a drop down will open suggesting ways to fix it.Bad command or file name. Bad, bad command! Sit! Stay! Staaaay... AntiTwitter: @DalekDave is now a follower!
-
Put the appropriate Using statement at the top of the class module and make sure you have included a reference to the appropriate assembly
Ya I had add all references for it!
-
public void ResetPassword(UserModel model, string Name)
{using (var db = new sortit\_internEntities()) { string emailAddress = (from info in db.users where info.name.Equals(model.Name) select info.email).Single(); if (!string.IsNullOrEmpty(emailAddress)) { string confirmationToken = WebSecurity.GeneratePasswordResetToken(model.Name); dynamic email = new Email("ChngPasswordEmail"); email.To = emailAddress; email.UserName = model.Name; email.ConfirmationToken = confirmationToken; email.Send(); } } }
for resetting password for login and yes I am new to MVC, this code is in business layer of MVC for kind Information
Nobody else caught this, but why are you using "dynamic"? It's not for the use case what you're using it. That line should read:
Email email = new Email("ChngPasswordEmail");
Dynamic treats your object as an Object type, removes all static checks at compile time, and slows down the code a bit due to having to resolve method calls at runtime. It also makes it harder to write the code and debug it. It should be rare that you have to use the dynamic type.
Asking questions is a skill CodeProject Forum Guidelines Google: C# How to debug code Seriously, go read these articles.
Dave Kreskowiak