2016-04-06 11 views
1

私はspire libを使ってユーザーのためにpdfファイルを作成しています。 (文献document_test =新しいドキュメント()){ document_test.LoadFromFile(は、FileNameTemplate)を用いGDI +で一般的なエラーが発生しました。 on Azure Webapp

string userId = User.Identity.GetUserId(); 
     User trainee = _userDAL.GetUserByIdentityId(userId); 

     // Get the Employee scores 
     string fileNameTemplate = Server.MapPath(Url.Content("~/assets/cert1-{0}-{1}.docx")); 
     string nnn = string.Format("cert1-{0}-{1}.pdf", trainee.StaffID, DateTime.Now.Millisecond); 
     string serverPath = MainConfig.P_EXPORT; 
     var folder = Server.MapPath(serverPath); 

  //Update Text of Title 
      document_test.Replace("#trainee_name#", trainee.Name, false, true); 
      document_test.Replace("#course_name#", "Test", false, true); 
      document_test.Replace("#date_info#", DateTime.Today.ToShortDateString(), false, true); 

      document_test.SaveToFile(nnn, Spire.Doc.FileFormat.PDF, System.Web.HttpContext.Current.Response, HttpContentType.Attachment); 
     } 

コードは、ローカルの開発マシン上で完璧に動作しますが、私はAzureのウェブアプリにアップロードしたとき、私は、この一般的なエラーが発生します。一般的なエラーは、GDI +で発生しました。

スタックトレース:

[ExternalExceptionが(0x80004005が):一般的なエラーは、GDI +で発生] System.Drawing.Imaging.Metafile..ctor(ストリームストリーム、のIntPtr referenceHdc、RectangleF frameRect、MetafileFrameUnit frameUnit、EmfType型、文字列の説明)+226801 System.Drawing.Imaging.Metafile..ctor(ストリームストリーム、IntPtr参照Hdc、RectangleF frameRect、MetafileFrameUnitフレーム単位、EmfType型)+34 sprᲦ。ᜀ(PageSetup A_0、ImageType A_1、MemoryStream A_2 、Int32 A_3、GraphicsUnit A_4)+255 sprᲦ。PageSetup A_0、ImageType A_1、MemoryStream A_2、Int32 A_3)+19 sprᲦ。᜔()+224(ストリームA_0)+94 Spire.Doc.Document.SaveToFile(ストリームストリーム、FileFormatファイルフォーマット) )289 Spire.Doc.Document.SaveToFile(文字列のファイル名、FileFormatはFILEFORMAT、のHttpResponse応答、HttpContentTypeのcontentType)673 LMSv1.Controllers.DisplayController.DownloadCertification(NULL可能1 tid, Nullable 1 EID)616 lambda_method(閉鎖、ControllerBase、オブジェクト[])+146 System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBaseコントローラー、オブジェクト[]パラメーター)+14 System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext、IDictionary 2 parameters) +167 System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary 2パラメーター)+27 System.Web.Mvc.Async.AsyncControllerActionInvoker.b__39(たIAsyncResult asyncResult、ActionInvocation innerInvokeState)22 System.Web.Mvc.Async.WrappedAsyncResult 2.CallEndDelegate(IAsyncResult asyncResult) +29 System.Web.Mvc.Async.WrappedAsyncResultBase 1.End()+49

+0

この問題は別のものが見つかりましたか? – Yogesh

+0

いいえ、私は必要なファイルを生成するために別のサーバーに依存しなければならず、そこからファイルをダウンロードしました。 – wandos

答えて

2

Azure Web Appsが実行するサンドボックスには、GDI +で動作している可能性の高い特定の呼び出しをブロックするいくつかの制限があります。

これらのサンドボックスの制限に関する詳細はhttps://github.com/projectkudu/kudu/wiki/Azure-Web-App-sandbox#win32ksys-user32gdi32-restrictionsにあります。

+0

はい、まさにそれが起こっていました.DGI +を利用するために別のサーバーを使用し、Azureに情報を戻していました。このリースを行うためのよりよい方法を発見した場合は、 – wandos

+0

を知らせてください。MicrosoftにはAzure Webアプリケーションでこれに対する代替ソリューションがありますか?または彼らは今度は画像処理をしないと言っている – Yogesh

0

ラフ推測:あなたは暗黙的に参照しています別のDLLがGACにインストールされているか、ローカルにコピーされません。したがって、コンパイルされたコードの大半はAzureに配備されていますが、問題のDLLは空白に展開されません。

+0

私はAzure Webアプリケーションのbinフォルダをチェックしており、dllはそこにあります。 – wandos

0

もう1つの暗い推測:http://www.e-iceblue.com/Introduce/free-pdf-component.htmlのドキュメントをチェックして、Azureで実行中に既知の問題がないかどうか確認してください。

+0

e-iceblue?それはspire.pdfとspire.docです。このdllはAzure Webアプリケーションでサポートされていません。 – Yogesh

0

この問題は、次のコードを使用して既に解決されているようです。同様の記事と解決策hereを参照してください。

Document doc = new Document(); 
doc.LoadFromFile(fileName); 
ToPdfParameterList tpl = new ToPdfParameterList{ 

    UsePSCoversion = true;   
    //azure   
}; 
doc.SaveToFile(resultName); 
関連する問題