I am using SharePoint foundation. I have a console application that is used to run some OCR process. I am calling the exe of the console application from windows service and it is working fine. I am trying to call the same exe from an event receiver but unable to call the exe and getting some error. The Event receiver is working fine but unable to call exe. I have tried to call the other exes like notepad.exe but getting same error. The details are below:


   public override void ItemAdded(SPItemEventProperties properties)

       Log("Event Occured.");
       string OCRedText = string.Empty;
       string Listname = properties.ListTitle;
       string itemName = Convert.ToString(properties.ListItem["Name"]);
       string itemTitle = Convert.ToString(properties.ListItem["Title"]);

       callService(); // Here is the method to call Process                

       SPListItem item = properties.ListItem;
       if (System.Threading.Monitor.TryEnter(myLock, TimeSpan.FromSeconds(100)))
           if (Convert.ToString(item["OCRed"]) == "False")
               item["OCRed"] = "True";
               Log("Item Added and Updated.");
               Log("Can not update the Item.");
       Log("Event End."+"\r\n");
   catch (Exception ex)
       Log("Error in Item Added Event Receiver.");

public void callService()
    Log("Calling Service is not easy.");
        ProcessStartInfo pinfoService = new ProcessStartInfo();
        pinfoService.FileName = @"D:\Khan\khan.exe";
        //pinfoService.FileName = @"C:\Windows\System32\notepad.exe";
        pinfoService.UseShellExecute = false;
        pinfoService.RedirectStandardError = true;
        pinfoService.RedirectStandardInput = true;
        pinfoService.RedirectStandardOutput = true;
        pinfoService.CreateNoWindow = true;
        pinfoService.WindowStyle = ProcessWindowStyle.Hidden;
        Log("FileName: " + pinfoService.FileName);
        Log("Arguments for callService : "+pinfoService.Arguments);
        Process pService = new Process();

        pService.StartInfo = pinfoService;
        Log("Process Before Start.");
        Log("Process Before wait for exit.");
        Log("Process Completed.");
    catch (Exception ex)
        Log("Error in callService(). Please contact your Administrator.");

and below is the error I am getting on pService.Start();


Info : Process Before Start.

Info : Error in callService(). Please contact your Administrator.

Info : System.ComponentModel.Win32Exception: Not enough quota is available to process this command

at System.Diagnostics.Process.StartWithCreateProcess(ProcessStartInfo startInfo)

at OCRonUploadDoc.EventReceiver1.EventReceiver1.callService()


I am unable to figure out the issue. Please help me...!!!

Thanks in Advance.

  • Khan Abubakar
  • Is that "notepad.exe" starting alright, or does it give same error? I assume you're not trying to use Sandboxed Solution for this? – Jussi Palo May 10 '12 at 7:59
  • Unable to call notepad.exe using above code. – MAK May 10 '12 at 9:12

I would highly recommend changing the solution to Farm from sandbox because your code is trying to call external processes on the OS. I believe you can easily do that from project properties in VS.

  • Thanks Emon. I have created an another solution "Farm solution" and it is able to call the process. I can do OCR on Item added Event Receiver. BTW I like Suggestion from @Paul Schaeflein so Planning to do the same. Because Event Receiver may get fail to work on Big file OCR. – MAK May 11 '12 at 11:34

Your architecture is completely wrong.

Event receivers are best for short, non-intensive operations. Anything that requires resources, such as loading an exe into a new process, should be performed outside of the event process.

As an example, the event receiver can queue a request that is processed by a service application. This model is how everything works in SharePoint (feature activation, workflows, etc.)

  • I agree, this should not be implemented as an event receiver, but an event receiver could be used to trigger the processing somewhere else, say a web service or timer job. – Daniel Symonds-Lloyd May 10 '12 at 22:55
  • Actually I want to do the OCR on document that is added now. So on Item Added Event the OCR should be done and then updating the Library about the document is OCRed or not. I have created Windows Service doing OCR on document in a Local folder and upload the document with OCR data in Library. To do the same on "Add Document" I have to use Item Added event. – MAK May 11 '12 at 5:05

I assume from the "Not enough quota is available to process this command" you are running this code as a Sandbox solution. You will not be able to execute it this way because of the restrictions of the sandbox.

You can try and increase the quota size by adding resource points, but you will probably run into an access denied error afterwards.

What are you actually trying to do with the console application, are you using it to get around some other limitation?

Have you tried to deploy the solution in the farm solution gallery, so the dll is running from the GAC?

  • Thanks Daniel for your response. 1) I am using an event receiver deployed as Sandbox solution. 2) Console Application is used to OCR the file and extract the text from different type of files. 3) It is Sandbox solution so not deployed in farm solution gallery. 4) Dll added in GAC. 5) This is an event receiver and I can log the comments too. but can not start a process. – MAK May 10 '12 at 12:58

Try changing web.config truest level from "WSS_Minimal" to "Full" to verify it isn't permission related. If "Full" solves your problem, figure out what CAS policy is preventing your code from working and create custom policy for it.

Remember to revert to "WSS_Minimal" after testing this.

  • Thanks @Jussi Palo for replying my question. Changed the trust level from "WSS_Minimal" to "Full" but not working. – MAK May 10 '12 at 9:37
  • 1
    No, no, no. Do not expose yourself to such risk. Ever. – Paul Schaeflein May 10 '12 at 15:40
  • "Trying with Full" doesn't mean "leave it to Full". Simple troubleshooting steps in scoping where the issue might be. Assemblies in GAC run with "Full" anyway. – Jussi Palo May 14 '12 at 9:53

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.