0

SharePoint Foundation を使用しています。OCR プロセスを実行するために使用するコンソール アプリケーションがあります。Windows サービスからコンソール アプリケーションの exe を呼び出していますが、正常に動作しています。イベント レシーバーから同じ exe を呼び出そうとしていますが、exe を呼び出すことができず、エラーが発生します。イベント レシーバーは正常に動作していますが、exe を呼び出すことができません。notepad.exeなどの他のexeを呼び出そうとしましたが、同じエラーが発生しました。詳細は以下のとおりです。

コード:

public override void ItemAdded(SPItemEventProperties properties)
{

   try
   {
       base.ItemAdded(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";
               Thread.Sleep(10000);
               item.SystemUpdate();
               Log("Item Added and Updated.");
           }
           else
           {
               Log("Can not update the Item.");
           }
       }
       Log("Event End."+"\r\n");
   }
   catch (Exception ex)
   {
       Log("Error in Item Added Event Receiver.");
       Log(ex.ToString());               
   }
}

public void callService()
{
    Log("Calling Service is not easy.");
    try
    {
        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.");
        Thread.Sleep(5000);
        pService.Start();
        Thread.Sleep(2000);
        Log("Process Before wait for exit.");
        pService.WaitForExit();
        Log("Process Completed.");
    }
    catch (Exception ex)
    {
        Log("Error in callService(). Please contact your Administrator.");
        Log(ex.ToString());
    }
}

以下は私が得ているエラーです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()

=========================================

私は問題を理解することができません。私を助けてください...!!!

前もって感謝します。

  • カーン・アブバカール
4

1 に答える 1

0

アプリケーション プールを実行する asp.net アカウントには、exe ファイルを起動する権限がないと思います。これを確認できます http://www.daniweb.com/web-development/aspnet/threads/386380/cannot-run-exe-files-in-asp.net-application ただし、システムがより多くのユーザーによって使用される場合ドキュメントを変更するたびに新しいプロセスが生成されるため、問題がすぐに発生する可能性があります。サーバーの RAM が不足し、ファームが使用できなくなります。

于 2012-05-10T06:46:25.360 に答える