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 9225527
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:35:56+00:00 2026-06-18T04:35:56+00:00

Simple NCron service: class Program { static void Main(string[] args) { var schedService =

  • 0

Simple NCron service:

class Program
{
    static void Main(string[] args)
    {
        var schedService = new SchedulingService();
        schedService.At("* * * * *").Run<MyTask>(); // run every minute
        schedService.Start();

        Console.ReadLine();
    }
}

public class MyTask : NCron.ICronJob
{
    public void Execute()
    {
        Console.WriteLine("executing");
    }

    public void Initialize(NCron.CronContext context)
    {
    }

    public void Dispose()
    {
    }
}

Upon reaching the first minute but before executing MyTask, NCron seems to want to write to the Windows Event Log, and fails with

Unhandled Exception: System.Security.SecurityException: The source was not found, but some or all event logs could not be searched.  To create the source, you need permission to read all event logs to make sure that the new source name is unique.  Inaccessible logs: Security.
   at System.Diagnostics.EventLogInternal.FindSourceRegistration(String source, String machineName, Boolean readOnly, Boolean wantToCreate)
   at System.Diagnostics.EventLogInternal.SourceExists(String source, String machineName, Boolean wantToCreate)
   at System.Diagnostics.EventLogInternal.VerifyAndCreateSource(String sourceName, String currentMachineName)
   at System.Diagnostics.EventLogInternal.WriteEntry(String message, EventLogEntryType type, Int32 eventID, Int16 category, Byte[] rawData)
   at System.Diagnostics.EventLog.WriteEntry(String message, EventLogEntryType type)
   at NCron.ExceptionHelper.LogUnhandledException(Object exception)
   at NCron.Service.SchedulingService.WaitCallbackHandler(Object data)
   at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(Object state)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
   at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
   at System.Threading.ThreadPoolWorkQueue.Dispatch()
   at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()`

What and why is NCron writing to the Event Log? This is the default behavior, so anyone using NCron must have dealt with this, I suppose, but I can’t find any documentation or question/answers about the issue. I tried setting schedService.LogFactory = null;, which doesn’t change anything.

Short of creating a custom log factory (which I don’t want to do), or fiddling with the registry (which I really don’t want to do, and sometimes can’t on production machines), how can I fix this?

  • 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-18T04:35:58+00:00Added an answer on June 18, 2026 at 4:35 am

    If you don’t want to write to the event log, you will need to provide an alternate logger and factory. As mentioned at the bottom of the https://code.google.com/p/ncron/wiki/Logging page, there’s a log4net implementation available, of which the most recent version seems to reside at https://github.com/schourode/ncron/tree/master/src/NCron.Integration.log4net. If you don’t want to use log4net, it would be quite trivial to write an alternate implementation.

    If you are willing to allow NCron to write to the event log, you can avoid the runtime SecurityException by creating the target event log under an admin account before running the service. This would typically be done by including creation of the event log in your installer (assuming you have one), for example by using an EventLogInstaller.

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

Sidebar

Related Questions

Simple syntactic c# question is this. Given this code: List<string> Columns = new List<string>();
Simple html: <div class=div1> <div class=test><span>1</span></div> <div class=test><span>2</span></div> </div> And js: var el =
Simple question: Is there a class or interface that encapulates the getting of a
Simple question - How do I convert a string that has been through parseInt
Simple program from DEITLE's book , read 5 integers and the program should print
Simple question: If you have a string x , to initialize it you simple
Simple question - in the CAKE php framework - in inflection.php (class inflection) why
Simple code: $(document).ready(function(){ console.log($('.slide-background').width()); }); and simple html: <div class=testdiv> <img class=slide-background src=img/slide.png/> </div>
Simple question about regexps. I've got String text = foobar1foobar1; And I need to
Simple question: Is there a way to run a script in the background with

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.