[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 612
  • Last Modified:

ASP.net Error "That assembly does not allow partially trusted callers"

The error i get is "System.Security.SecurityException: That assembly does not allow partially trusted callers"

The Code Is as follows

 Dim doc As Document = New Document
        Dim PDFMemoryStream As MemoryStream = New MemoryStream()
        'PdfWriter.GetInstance(doc, New FileStream(Request.PhysicalApplicationPath + "\1.pdf", FileMode.Create))
        Dim MyPdfWriter = PdfWriter.GetInstance(doc, PDFMemoryStream)
        MyPdfWriter.CloseStream = False

        doc.Open()
        doc.Add(New Paragraph("This Is A Test"))
        doc.Close()

        PDFMemoryStream.Position = 0

        Dim bytes As Byte() = PDFMemoryStream.ToArray

        'Use the following to create on the fly without saving
        Response.Clear()
        Response.ContentType = "application/pdf"
        Response.AddHeader("Content-Disposition", "attachment;filename=\Invoice.pdf")
        Response.BinaryWrite(bytes)
        Response.Flush()
        Response.End()
0
taz8020
Asked:
taz8020
3 Solutions
 
käµfm³d 👽Commented:
It looks like you are using an assembly which is not signed (the one housing PDFMemoryStream). You may have to change the security policy for .NET on your web server, but you might try this first:  http://msdn.microsoft.com/en-us/library/8skskf63.aspx
0
 
taz8020Author Commented:
I have checked the trust level in IIS7 and its set to full(internal) any ideas?
0
 
taz8020Author Commented:
Hi Thanks all, it was the trust isssue. Iw was set to full intenal but when set to just full then it worked.
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now