GDI +中发生一般性错误。在Azure上的webapp [英] A generic error occurred in GDI+. on Azure Webapp
问题描述
我使用的塔尖lib中创建PDF文件的用户。
I am using spire lib to create pdf files for the user.
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);
使用(文档document_test =新的文件())
{
document_test.LoadFromFile(fileNameTemplate);
using (Document document_test = new Document()) { document_test.LoadFromFile(fileNameTemplate);
//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);
}
在code完美的作品在本地开发机器上,但是当我把它上传到Azure的Web应用程序,我得到一本普通的错误:GDI +中发生一般性错误。
The Code works perfectly on the local development machine, but when i upload it to Azure web app i get a this generic error: A generic error occurred in GDI+.
堆栈跟踪:
[ExternalException(0X80004005):GDI +中发生一般性错误。]
System.Drawing.Imaging.Metafile..ctor(流流,IntPtr的referenceHdc,的RectangleF frameRect,MetafileFrameUnit frameUnit,EmfType类型,字符串描述)226801
System.Drawing.Imaging.Metafile..ctor(流流,IntPtr的referenceHdc,的RectangleF frameRect,MetafileFrameUnit frameUnit,EmfType型)+34
sprᲦ。ᜀ(PAGESETUP A_0,A_1将ImageType,MemoryStream的A_2,A_3的Int32,GraphicsUnit A_4)+255
sprᲦ。ᜀ(PAGESETUP A_0,A_1将ImageType,MemoryStream的A_2,A_3的Int32)+19
sprᲦ。᜔()+224
sprᲦ。ᜁ(的IDocument A_0)+234
SPR᧤.ᜀ(文档A_0)+93
Spire.Doc.Document。ᜀ(流A_0)+94
Spire.Doc.Document.SaveToFile(流流,FILEFORMAT FILEFORMAT)289
Spire.Doc.Document.SaveToFile(字符串文件名,FILEFORMAT FILEFORMAT,Htt的presponse响应,HttpContentType的contentType)673
LMSv1.Controllers.DisplayController.DownloadCertification(可空 1 TID,可为空
1 EID)616
lambda_method(封闭,ControllerBase,对象[])+146
System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase控制器,对象[]参数)+14
System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext,IDictionary的 2参数)+167
2参数)+27
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext,ActionDescriptor actionDescriptor,IDictionary的
System.Web.Mvc.Async.AsyncControllerActionInvoker.b__39(IAsyncResult的asyncResult,ActionInvocation innerInvokeState)+22
System.Web.Mvc.Async.WrappedAsyncResult 2.CallEndDelegate(IAsyncResult的asyncResult)+29
1.End()+49
System.Web.Mvc.Async.WrappedAsyncResultBase
[ExternalException (0x80004005): A generic error occurred in GDI+.]
System.Drawing.Imaging.Metafile..ctor(Stream stream, IntPtr referenceHdc, RectangleF frameRect, MetafileFrameUnit frameUnit, EmfType type, String description) +226801
System.Drawing.Imaging.Metafile..ctor(Stream stream, IntPtr referenceHdc, RectangleF frameRect, MetafileFrameUnit frameUnit, EmfType type) +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
sprᲦ.ᜁ(IDocument A_0) +234
spr᧤.ᜀ(Document A_0) +93
Spire.Doc.Document.ᜀ(Stream A_0) +94
Spire.Doc.Document.SaveToFile(Stream stream, FileFormat fileFormat) +289
Spire.Doc.Document.SaveToFile(String fileName, FileFormat fileFormat, HttpResponse response, HttpContentType contentType) +673
LMSv1.Controllers.DisplayController.DownloadCertification(Nullable1 tid, Nullable
1 eid) +616
lambda_method(Closure , ControllerBase , Object[] ) +146
System.Web.Mvc.ActionMethodDispatcher.Execute(ControllerBase controller, Object[] parameters) +14
System.Web.Mvc.ReflectedActionDescriptor.Execute(ControllerContext controllerContext, IDictionary2 parameters) +167
System.Web.Mvc.ControllerActionInvoker.InvokeActionMethod(ControllerContext controllerContext, ActionDescriptor actionDescriptor, IDictionary
2 parameters) +27
System.Web.Mvc.Async.AsyncControllerActionInvoker.b__39(IAsyncResult asyncResult, ActionInvocation innerInvokeState) +22
System.Web.Mvc.Async.WrappedAsyncResult2.CallEndDelegate(IAsyncResult asyncResult) +29
System.Web.Mvc.Async.WrappedAsyncResultBase
1.End() +49
推荐答案
这是Azure的Web应用程序下运行的沙箱具有阻止某些调用一些限制,这很可能是你与GDI +运行到什么
The sandbox that Azure Web Apps run under has some restrictions which blocks certain calls, which is likely what you're running into with GDI+.
您可以找到关于<一个沙盒的那些限制的更多信息href=\"https://github.com/projectkudu/kudu/wiki/Azure-Web-App-sandbox#win32ksys-user32gdi32-restrictions\" rel=\"nofollow\">https://github.com/projectkudu/kudu/wiki/Azure-Web-App-sandbox#win32ksys-user32gdi32-restrictions.
这篇关于GDI +中发生一般性错误。在Azure上的webapp的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!