Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6979607
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:54:30+00:00 2026-05-27T17:54:30+00:00

everyone, I have problems when using MVC3 code is as follows public SystemController(IRepository repository)

  • 0

everyone, I have problems when using MVC3 code is as follows

 public SystemController(IRepository repository)
            :this
        (
            repository,
            new AspNetMembershipProviderWrapper(System.Web.Security.Membership.Provider),
                new AspNetMembershipProviderWrapper(System.Web.Security.Membership.Provider),
                new AspNetRoleProviderWrapper(Roles.Provider),
            new SmtpClientProxy(new SmtpClient(Utils.Setting.EmailServer,
                                               int.Parse(Utils.Setting.EmailPort))
                                    {
                                        EnableSsl = true,
                                        UseDefaultCredentials = true,
                                        Credentials = new NetworkCredential(Utils.Setting.EmailAccount,
                                                                            Utils.Setting.EmailPassword),
                                        DeliveryMethod = SmtpDeliveryMethod.Network
                                    })
       ){}



        public SystemController(IRepository repository,
            IUserService userService,
            IPasswordService passwordService,
            IRolesService rolesService,
            ISmtpClient smtpClient)
            : base(repository)
        {
            _userService = userService;
            _passwordService = passwordService;
            _rolesService = rolesService;
            _smtpClient = smtpClient;
        }

public class SmtpClientProxy : ISmtpClient
    {
        private readonly SmtpClient _smtpClient;

        public SmtpClientProxy(SmtpClient smtpClient)
        {
            _smtpClient = smtpClient;
        }

        #region ISmtpClient Members

        public void Send(MailMessage mailMessage)
        {
            _smtpClient.Send(mailMessage);
        }

        #endregion
    }

 ObjectFactory.Initialize(x =>
                                 {
                                     x.Scan(scanner =>
                                                {
                                                    scanner.TheCallingAssembly();
                                                    scanner.WithDefaultConventions();
                                                });
                                     x.For<ISessionFactory>()
                                         .Singleton()
                                         .Use(GetSessionFactory());
                                     x.For<ISession>()
                                         .HybridHttpOrThreadLocalScoped()
                                         .Use(y => y.GetInstance<ISessionFactory>().OpenSession());
                                     x.For<IUserService>()
                                         .Use<AspNetMembershipProviderWrapper>();
                                     x.For<IPasswordService>()
                                         .Use<AspNetMembershipProviderWrapper>();
                                     x.For<IPasswordService>()
                                         .Use<AspNetMembershipProviderWrapper>();
                                     x.For<IRolesService>()
                                         .Use<AspNetRoleProviderWrapper>();
                                     x.For<ISmtpClient>()
                                         .Use<SmtpClientProxy>().Ctor<SmtpClient>();
                                     x.For<MembershipProvider>()
                                         .Use(System.Web.Security.Membership.Provider);
                                     x.For<RoleProvider>()
                                       .Use(Roles.Provider);
                                 });

Error info:

StructureMap Exception Code: 202
No Default Instance defined for PluginFamily System.Net.Mail.SmtpClient, System, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089


I think the problem lies in this:

x.For <ISmtpClient> ()
. Use <SmtpClientProxy> (). Ctor <SmtpClient> ();

I ask you how to write it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T17:54:31+00:00Added an answer on May 27, 2026 at 5:54 pm

    Your SmtpClientProxy class requires an SmtpClient class in its constructor. You don’t have anything registered for SmtpClient.

    Try adding this to your registration:

    x.For<SmtpClient>().Use<SmtpClient>(); 
    

    This assumes that SmtpClient does not take dependencies in its constructor. If it does you will likely get an error that one of its dependencies are not registered with a default implementation.

    Alternatively you could change the constructor code to this (no constructor dependency):

    private readonly SmtpClient _smtpClient = new SmtpClient();  
    
    public SmtpClientProxy()  
    {  
    }  
    

    Without knowing what you are trying to do, it’s hard to answer definitively.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a central git repository that everyone pushes to for testing and integration,
Very new to PHP5 and have some problems still. I figured out how to
Why does everyone tell me writing code like this is a bad practice? if
We have a button that saves asynchronously using AjaxToolKit/C#/.NET. I'm getting this in my
Everyone, I'm using MVC 3 (Razor). I have the following problem: I have some
I have a problem in my project with the .designer which as everyone know
Hi everyone my problem today is I have a couple of buttons that slide
hey everyone, here is the site SEE BELOW I have a slight jquery problem
I have a project which contains different components that everyone works on. We have
Hello everyone Masters Of Web Delevopment :) I have a piece of PHP script

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.