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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T15:30:43+00:00 2026-06-15T15:30:43+00:00

Inside of a public class: public static class LogReporting I have the following method:

  • 0

Inside of a public class:

    public static class LogReporting

I have the following method:

    public void RunTimerJobs()
    {
        SPAdministrationWebApplication centralAdmin = SPAdministrationWebApplication.Local;
        try
        {
            foreach (SPService service in centralAdmin.Farm.Services)
            {
                Guid traceGuid = new Guid("d3beda82-38f4-4bc7-874f-ad45cebc9b35");
                Guid eventGuid = new Guid("3ea057b3-0391-4c33-ac8d-412aecdda97d");

                var traceJob =
                    from jobDefinition in service.JobDefinitions
                    where jobDefinition.Id == traceGuid
                    select jobDefinition;

                if (traceJob != null && traceJob.Count() == 1)
                {
                    traceJob.First().RunNow();
                }

                var eventJob =
                    from jobDefinition in service.JobDefinitions
                    where jobDefinition.Id == eventGuid
                    select jobDefinition;

                if (eventJob != null && eventJob.Count() == 1)
                {
                    eventJob.First().RunNow();
                }
            }
        }
        catch (Exception ex)
        {
            //Loggers.SharePointLogger logger = new Loggers.SharePointLogger();
            //logger.WriteTrace(ex.Message, LogProduct.MonitoringView, LogTraceSeverity.Unexpected);
        }

However it will not allow me to compile citing that RunTimerJobs() “cannot declare instance members in a static class”
To my knowledge, none of the ‘instance members’ I declare are able to be labeled as static, so is there just a fundamental issue with the setup (i.e. a static class) or am I missing some little snippet?

  • 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-15T15:30:45+00:00Added an answer on June 15, 2026 at 3:30 pm

    Your class is static thus you cannot have any instance members because you will never instantiate the class.

    To be able to use the RunTimerJobs() method you would need to create an instance of the LogReporting class, i.e.

    LogReporting logReporting = new LogReporting();
    logReporting.RunTimerJobs();
    

    This obviously won’t work though because your class is defined as static and you cannot create instances of it.

    Either make your method static or remove the static keyword from your class declaration – depending on what you require.

    I see no instance related logic in your method so it should be safe to mark it as static.

    Remember

    Classes can have a mixture of instance and static members as long as the class isn’t marked static.

    And

    Only mark classes as static when you know that ALL members (properties, methods etc…) will be static as well.

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

Sidebar

Related Questions

I have the following dependency property inside a class: class FooHolder { public static
I have this getView method inside my ListViewAdapter: public static class ViewHolder{ public TextView
I have the following generic class: public class MessageProcesser<T> where T : Message Inside
I've got a static method inside Utility class : public static final <T extends
I have the following java code: public class CheckInnerStatic { private static class Test
So I have a class with a wrapper class inside like so: public class
I have a list of Persons inside a Company Class. public class Company{ IList<Person>
I have a class level price variable decalred inside a page, like this: public
If I have a static class: public static class Foo { public static string
I have a custom dialog inside public class NewPartnerDialog extends Dialog implements OnClickListener And

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.