TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Willem
NA
3
0
Security exception when constructing system.net.mail.smtpClient. Need smtpPermission?
Mar 2 2010 6:19 AM
Hi all,
This is my first post, i'm very much a noobie, so sorry if this is an obvious one.
I am studying the 70-536 self paced training kit and using VS2010 for the excercises. In Chapter 15 : Mail the excersise is to create a mail sender application.
When I follow the steps they give it throws a security exception with the following message at the constructor of the smtpClient class:
Request for the permission of type 'System.Net.Mail.SmtpPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
The finished code sample that they supply with the book also throws the same exception.
I have tried adding a permission.requestminimum attribute to the assembly and the code runs. I'm assuming it means that it has the nescesary permissions then, otherwise it would not have been able to run.
So far the code looks something like this:
//in assembly info file
[assembly: System.Net.Mail.SmtpPermission(System.Security.Permissions.SecurityAction.RequestMinimum)]
//above mail sender method
[SmtpPermission (System.Security.Permissions.SecurityAction.Demand)]
...omminting setup code...
// Configure the mail server
SmtpClient sc = new SmtpClient(serverTextBox.Text);
Thank you for any help.
Reply
Answers (
2
)
database on webserver could not connected on local machine
delete datagrid images in saved directory