Solved

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

Posted on 2012-04-04
5
600 Views
Last Modified: 2012-06-27
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
Comment
Question by:taz8020
5 Comments
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 167 total points
ID: 37805623
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
 
LVL 5

Assisted Solution

by:Vishal Kedar
Vishal Kedar earned 167 total points
ID: 37805881
0
 
LVL 3

Author Comment

by:taz8020
ID: 37806097
I have checked the trust level in IIS7 and its set to full(internal) any ideas?
0
 
LVL 83

Assisted Solution

by:CodeCruiser
CodeCruiser earned 166 total points
ID: 37807666
0
 
LVL 3

Author Closing Comment

by:taz8020
ID: 37815327
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

730 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question