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

  • SEARCH
  • Home
  • 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 8826157
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T07:04:05+00:00 2026-06-14T07:04:05+00:00

I try to create a static function in Nop.Services.Customers.CustomerService for get customer list in

  • 0

I try to create a static function in Nop.Services.Customers.CustomerService for get

customer list in the nop database. I want to call this function in an external Console

Application. But CustomerService class not contains the default constructor.

Please see the constructor code.

  #region Ctor

    /// <summary>
    /// Ctor
    /// </summary>
    /// <param name="cacheManager">Cache manager</param>
    /// <param name="customerRepository">Customer repository</param>
    /// <param name="customerRoleRepository">Customer role repository</param>
    /// <param name="customerAttributeRepository">Customer attribute repository</param>
    /// <param name="encryptionService">Encryption service</param>
    /// <param name="newsLetterSubscriptionService">Newsletter subscription service</param>
    /// <param name="rewardPointsSettings">Reward points settings</param>
    /// <param name="customerSettings">Customer settings</param>
    /// <param name="eventPublisher"></param>
    public CustomerService(ICacheManager cacheManager,
        IRepository<Customer> customerRepository,
        IRepository<CustomerRole> customerRoleRepository,
        IRepository<CustomerAttribute> customerAttributeRepository,
        IEncryptionService encryptionService, INewsLetterSubscriptionService newsLetterSubscriptionService,
        RewardPointsSettings rewardPointsSettings, CustomerSettings customerSettings,
        IEventPublisher eventPublisher)
    {
        _cacheManager = cacheManager;
        _customerRepository = customerRepository;
        _customerRoleRepository = customerRoleRepository;
        _customerAttributeRepository = customerAttributeRepository;
        _encryptionService = encryptionService;
        _newsLetterSubscriptionService = newsLetterSubscriptionService;
        _rewardPointsSettings = rewardPointsSettings;
        _customerSettings = customerSettings;
        _eventPublisher = eventPublisher;
    }

    #endregion

And Fileds is shows the error when try to call in the static function.

Please see the fields

  #region Fields

    private readonly IRepository<Customer> _customerRepository;
    private readonly IRepository<CustomerRole> _customerRoleRepository;
    private readonly IRepository<CustomerAttribute> _customerAttributeRepository;
    private readonly IRepository<FileUpload> _fileuploadRepository;
    private readonly IEncryptionService _encryptionService;
    private readonly ICacheManager _cacheManager;
    private readonly INewsLetterSubscriptionService _newsLetterSubscriptionService;
    private readonly RewardPointsSettings _rewardPointsSettings;
    private readonly CustomerSettings _customerSettings;
    private readonly IEventPublisher _eventPublisher;

    #endregion

I create a default in CustomerService class.

 public CustomerService()
 {
 }

and create new function in CustomerService

 public virtual List<Customer> GetClients()
    {
        var _cust = _customerRepository.Table;

        return _cust.ToList();
    }

and call this function in an external console application

    private static CustomerService _customerService = new CustomerService();
    static void Main(string[] args)
    {
        List<Customer> cust = _customerService.GetClients();

        ThreadStart start = new ThreadStart(ProcessMails);
        thread = new Thread(start);
        ProcessStatus = 1;
        thread.Start();
    }

But when i call this function it’s shows the null error.

enter image description here

It’s not possible to create a function in Nop.Core and call in an external application?

Please help.

  • 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-06-14T07:04:06+00:00Added an answer on June 14, 2026 at 7:04 am

    From class definition, it is not possible. Static methods are for the type, not for the instance, so the member variable can be used in a static method should be static too.

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

Sidebar

Related Questions

I get this SoapFault I dont understand. Calling the function below, codewordStemExists(), should create
Check this function. private static IEnumerable<string> FindAccessibleDatabases() { var connectionStrings = new List<string>(); Parallel.For(0,
I want to create a generic function with signature like this : void funcName<T>()
I get this error when i try to run the program: Error C2440: 'function'
I try to create a multi-threaded singleton pattern class. Header: class HL{ public: static
I want to try create something like Zend's Server Pagecache. What I want to
Im try to create a spinner dynamically on press of a button. this is
I want to create the same function Find windows... of spy++ in C#. I
In Codeigniter, when we use $this->load('class_name') in the controller, CI will try to create
I'm trying to create a function that adds usercontrols to my mainform. I want

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.