Security exception using System.Net.Mail in a class library

V

venner

Hi group,
I am currently developing two websites that will work together, but for
several reasons are seperated into two projects. I am developing in
ASP.NET 2.0 using VS2005. In my solution I have 3 projects: the two
web sites and a class library that contains some code shared by both
websites.

I have noticed that if I try to use certain libraries (notably
System.Net.Mail and System.Data.SqlClient) I get a Security Exception.
The text of the exeption for System.Net.Mail follows:

System.Security.SecurityException: Request for the permission of type
'System.Net.Mail.SmtpPermission, System, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

I have played around with Attributes trying to get the CLR to grant the
assembly the required permissions I added the following line to the
class where I have the call to the SmtpClient object, but to no avail:

[assembly:
SmtpPermission(System.Security.Permissions.SecurityAction.RequestOptional,
Unrestricted=true)]

Does anybody know how I can make use of System.Net.Mail from a class
library?

Thanks,
Eric
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,008
Latest member
HaroldDark

Latest Threads

Top