2

I've been working o a Timerjob project. All of a sudden, when I try to deploy the solution from VS, I got this error:

Error 1 Error occurred in deployment step 'Add Solution': Specified argument was out of the range of valid values.

using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
using System.Security.Permissions;
using Microsoft.SharePoint;
using Microsoft.SharePoint.Administration;
using Microsoft.SharePoint.Security;

    namespace SendMailDaily.Features.Feature1
    {
        /// <summary>
        /// This class handles events raised during feature activation, deactivation, installation, uninstallation, and upgrade.
        /// </summary>
        /// <remarks>
        /// The GUID attached to this class may be used during packaging and should not be modified.
        /// </remarks>

        [Guid("10f9856c-4b91-4681-8b06-216ac0a8b253")]
        public class Feature1EventReceiver : SPFeatureReceiver
        {
            string JobName = "SendMailDaily"; 
            const string CONFIGURATION_LIST = "SendMail_config_List";
            private static Logger loggerObjFeature = new Logger("c:\\temp\\log\\", "SendMailDaily_Feature");


            public override void FeatureActivated(SPFeatureReceiverProperties properties)
            {
                try
                {
                    loggerObjFeature.writeLog("Begin");
                    SPSecurity.RunWithElevatedPrivileges(delegate()
                    {
                        SPWebApplication parentWebApp = (SPWebApplication)properties.Feature.Parent;
                        SPSite site =  parentWebApp.Sites[0];
                        DeleteExistingJob(JobName, parentWebApp);
                        CreateConfigList(site);
                        CreateJob(parentWebApp);
                    });
                    loggerObjFeature.writeLog("End");
                }
                catch (Exception ex)
                {
                    loggerObjFeature.writeLog("Errore:" + ex.Message);
                    throw ex;
                }

            }
            private bool CreateJob(SPWebApplication site)
            {
                bool jobCreated = false;
                try
                {
                    loggerObjFeature.writeLog("Begin");
                    SendMailDaily job = new SendMailDaily(JobName, site);
                    //SPMinuteSchedule schedule = new SPMinuteSchedule();
                    //schedule.BeginSecond = 0;
                    //schedule.EndSecond = 59;
                    //schedule.Interval = 15;
                    //job.Schedule = schedule;

                    job.Update();
                    loggerObjFeature.writeLog("End");
                }
                catch (Exception ex)
                {
                    loggerObjFeature.writeLog("Errore:" + ex.Message);
                    return jobCreated;
                }
                return jobCreated;
            }
            public bool DeleteExistingJob(string jobName, SPWebApplication site)
            {
                bool jobDeleted = false;
                try
                {
                    loggerObjFeature.writeLog("Begin");
                    foreach (SPJobDefinition job in site.JobDefinitions)
                    {
                        if (job.Name == jobName)
                        {
                            job.Delete();
                            jobDeleted = true;
                        }
                    }
                    loggerObjFeature.writeLog("End");
                }
                catch (Exception ex)
                {
                    loggerObjFeature.writeLog("Errore:" + ex.Message);
                    return jobDeleted;
                }
                return jobDeleted;
            }
            public override void FeatureDeactivating(SPFeatureReceiverProperties properties)
            {

                lock (this)
                {
                    try
                    {
                        loggerObjFeature.writeLog("Begin");
                        SPSecurity.RunWithElevatedPrivileges(delegate()
                        {
                            SPWebApplication parentWebApp = (SPWebApplication)properties.Feature.Parent;
                            DeleteExistingTimerJobFromSite(this.JobName, parentWebApp);
                        });
                        loggerObjFeature.writeLog("End");
                    }
                    catch (Exception ex)
                    {
                        loggerObjFeature.writeLog("Errore:" + ex.Message);
                        throw ex;
                    }
                }
            }
            public void DeleteExistingTimerJobFromSite(string jobname, SPWebApplication parentWebApp)
            {
                try
                {
                    loggerObjFeature.writeLog("Begin");
                    SendMailDaily job = new SendMailDaily(JobName, parentWebApp);

                    job.Delete();
                    loggerObjFeature.writeLog("End");
                }
                catch (Exception ex)
                {
                    loggerObjFeature.writeLog("Errore:" + ex.Message);
                    throw;
                }

            } 
            public void CreateConfigList(SPSite site)
            {
                List<SPField> fields = new List<SPField>();
                  loggerObjFeature.writeLog("BEGIN");
                try
                {

                    if (DeleteList())
                    {
                        // Create List
                        Guid ListId = site.RootWeb.Lists.Add(CONFIGURATION_LIST, "Questa lista è destinata alla configurazione dei parametri per il funzionamento del QueryMailtimerJob.", SPListTemplateType.GenericList);
                        site.RootWeb.Lists[ListId].OnQuickLaunch = true;
                        site.RootWeb.Lists[ListId].Update();
                        // Create List Fields
                        String MY_CONN = site.RootWeb.Lists[ListId].Fields.Add("myConn".ToLower(), SPFieldType.Text, true);
                        String SHAREPOINT = site.RootWeb.Lists[ListId].Fields.Add("sharepoint".ToLower(), SPFieldType.Text, true);
                        String LIBRARY = site.RootWeb.Lists[ListId].Fields.Add("library".ToLower(), SPFieldType.Text, true);
                        String MAIL_LIST = site.RootWeb.Lists[ListId].Fields.Add("MailList".ToLower(), SPFieldType.Text, true);
                        String TESTELMEC = site.RootWeb.Lists[ListId].Fields.Add("TestElmec".ToLower(), SPFieldType.Text, true);
                        //Create View
                        SPList ConfigList = site.RootWeb.Lists[ListId];
                        SPView defaultView = ConfigList.DefaultView;
                        defaultView.ViewFields.Add(ConfigList.Fields[MY_CONN]);
                        defaultView.ViewFields.Add(ConfigList.Fields[SHAREPOINT]);
                        defaultView.ViewFields.Add(ConfigList.Fields[LIBRARY]);
                        defaultView.ViewFields.Add(ConfigList.Fields[MAIL_LIST]);
                        defaultView.ViewFields.Add(ConfigList.Fields[TESTELMEC]);
                        defaultView.Update();
                        site.RootWeb.Update(); 
                         loggerObjFeature.writeLog("END");
                    }

                }
                catch(Exception exception)
                {
                    loggerObjFeature.writeLog("Errore:"+exception.Message);

                }
            }
            public bool DeleteList()
            {
                using (SPWeb web = SPContext.Current.Site.RootWeb)
                {    loggerObjFeature.writeLog("BEGIN");
                    try
                    {
                        if (web.Lists.TryGetList(CONFIGURATION_LIST) != null)
                        {
                            web.Lists.Delete(web.Lists[CONFIGURATION_LIST].ID);
                            web.Update();
                        }
                         loggerObjFeature.writeLog("END");
                        return true;
                    }
                    catch(Exception exception)
                    {
                         loggerObjFeature.writeLog("Errore:"+exception.Message);
                        return false;
                    }
                }
            }
        }
    }
  • I am also facing this issue. Could you let me know how you resolved it. – user43248 Jun 13 '15 at 14:53
0

I solved this problem. It's your schedule.

                SPMinuteSchedule schedule = new SPMinuteSchedule();
                schedule.BeginSecond = 0;
                schedule.EndSecond = 59;
                schedule.Interval = 15;
                job.Schedule = schedule;
0

I also received this kind of error before while deploying webpart, so I used powershell to add solution, that time it shown the actual error that my SharePoint_Config log file was full.

You can check below two scenario:

  1. Your SharePoint_config log file is not full and you have disk space on server.
  2. The account you are using to deploy solution has rights to perform the deployment.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.