Solved

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

Posted on 2012-04-04
5
591 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 74

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

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Visual Studio: built-in keystroke automation 2 26
getting id from database 5 24
C# Error - Add Failed 12 53
Adjust the position 3 14
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

747 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now