Free Support Forum - aspose.com

Error when concatenating streams in ASP.NET hosted environment

Hi:


I am evaluating Aspose.Pdf.Kit and I am getting an error when I try to concatenate streams into 1 single out stream. This worked fine for me on my local development machine but when I moved my code to our development web server it started crashing. The following is the error I am getting:

System.TypeInitializationException: The type initializer for
‘Aspose.Pdf.Kit.PdfFileInfo’ threw an exception. —>
System.Security.SecurityException: Request for the permission of type
‘System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089’ failed. at
System.Security.CodeAccessSecurityEngine.Check(Object demand,
StackCrawlMark& stackMark, Boolean isPermSet) at
System.Security.CodeAccessPermission.Demand() at
System.Reflection.Assembly.VerifyCodeBaseDiscovery(String codeBase) at
System.Reflection.Assembly.GetName(Boolean copiedName) at
System.Reflection.Assembly.GetName() at Aspose.Pdf.Kit.PdfFileInfo…cctor() The
action that failed was: Demand The type of the first permission that failed was:
System.Security.Permissions.FileIOPermission The first permission that failed
was: The demand was for: The granted set of the failing assembly was: The assembly or AppDomain
that failed was: Aspose.Pdf.Kit, Version=4.2.0.0, Culture=neutral,
PublicKeyToken=ae9e610db67fc2c1 The Zone of the assembly that failed was:
Trusted The Url of the assembly that failed was:
file://trcr.com/dfs1/WebCode/vdevweb01/wwwroot/WebConsole/bin/Aspose.Pdf.Kit.DLL
— End of inner exception stack trace — at
Aspose.Pdf.Kit.PdfFileEditor.Concatenate(Stream[] inputStreams, Stream
outputStream) at _PrintDocs.MergePDFandDisplay(String[] vwjobs) in
\trcr.com\dfs1\WebCode\vdevweb01\wwwroot\WebConsole\PrintDocs.aspx.cs:line 64

The follwoing is hte code where the error happens:
PdfFileEditor pdfEditor = new PdfFileEditor();
pdfEditor.Concatenate(streams, outStream);

streams is an ArrayList containing multiple converted to PDF Memory Streams. outStream is a single MemoryStream

Hi Michael,

Can you please share a little details regarding your server environment? i.e. Machine Specifications (32-bit or 64-bit), OS details, .NET Framework, IIS etc. Please share the details so we could investigate the issue at our end.

We’re sorry for the inconvenience.
Regards,

The server is a 32bit MS Windows Server 2003 R2 Standard Edition with Service Pack 2. .NET Framework is 2.0.50727. IIS 6.

Thank you.

Hi,

I think that's append because when the code is executing, the authentification type is "NETWORK SERVICE" and so you must give this right to access your file.

Hope that helps

Hi Michael,

If you note the exception you shared earlier:
System.TypeInitializationException: The type initializer for
‘Aspose.Pdf.Kit.PdfFileInfo’ threw an exception. —>
System.Security.SecurityException:

The exception seems to occur with PdfFileInfo class; and most probably it is occurring while opening the PDF file, and not while concatenating the files.

Can you please try to assign appropriate permissions to the folders containing the files? If you still find the problem then please do let us know.

We’re sorry for the inconvenience.
Regards,