473,396 Members | 1,886 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Newbie Question: System.Security.SecurityException?

Ben
Hi,

I'm new to VB.Net programming, and am trying to learn VB using the new
Visual Studeio 2008 Express Edition. I've decided just to jump
straight in and try to program a simple mail form with 3 fields, 'to',
'subject' & 'body'. Running through the debugger, most of the code
seems to work, however I keep getting the following security error,
even though I have set the application as a full trusted application.

A first chance exception of type 'System.Security.SecurityException'
occurred in MyApplication.exe

Request for the permission of type
'System.Web.AspNetHostingPermission, System, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

The code that this happens on is the line below with the Call function
in.

Private Sub SendMail_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles SendMail.Click
Call SendMailSub(StrMailTo.Text, StrMailSub.Text,
StrMailBody.Text)
MsgBox("Your Messege Has Been Sent", MsgBoxStyle.Information,
"Messege Sent")
End Sub

Can anyone please help with this error?

Many thanks

Ben
Jun 27 '08 #1
3 2167
And the exact line is ? I assume it would be rather inside "SendMailSub".
The weird thing is that this is AspNetHostingPermission which should likely
be used in ASP.NET application. This is a Windows application ? What are you
using in the System.Web namespace ?

If you are using System.Web.MailMessage this is obsoleted. You may want to
try using System.Net.Mail instead as the comiler should have warned you...

--
Patrice
"Ben" <bj*********@hotmail.coma écrit dans le message de groupe de
discussion :
53**********************************...oglegroups.com...
Hi,

I'm new to VB.Net programming, and am trying to learn VB using the new
Visual Studeio 2008 Express Edition. I've decided just to jump
straight in and try to program a simple mail form with 3 fields, 'to',
'subject' & 'body'. Running through the debugger, most of the code
seems to work, however I keep getting the following security error,
even though I have set the application as a full trusted application.

A first chance exception of type 'System.Security.SecurityException'
occurred in MyApplication.exe

Request for the permission of type
'System.Web.AspNetHostingPermission, System, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

The code that this happens on is the line below with the Call function
in.

Private Sub SendMail_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles SendMail.Click
Call SendMailSub(StrMailTo.Text, StrMailSub.Text,
StrMailBody.Text)
MsgBox("Your Messege Has Been Sent", MsgBoxStyle.Information,
"Messege Sent")
End Sub

Can anyone please help with this error?

Many thanks

Ben

Jun 27 '08 #2
Ben wrote:
I'm new to VB.Net programming, and am trying to learn VB using the new
Visual Studeio 2008 Express Edition. I've decided just to jump
straight in and try to program a simple mail form with 3 fields, 'to',
'subject' & 'body'. Running through the debugger, most of the code
seems to work, however I keep getting the following security error,
even though I have set the application as a full trusted application.

A first chance exception of type 'System.Security.SecurityException'
occurred in MyApplication.exe

Request for the permission of type
'System.Web.AspNetHostingPermission, System, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
What /sort/ of application is this?
".exe" implies a Windows Forms or Console application, but ASPnet
[usually] brings the "Web" stuff into play.
The code that this happens on is the line below with the Call function
in.
I would say that was unlikely. There's nothing in that line to suggest
any need for additional security permissions.

Have you tried catching the Exception and displaying its StackTrace,
which will tell which routine actually failed?
That would give you a little more to work on:

Private Sub SendMail_Click( _
ByVal sender As System.Object _
, ByVal e As System.EventArgs _
) Handles SendMail.Click
Try

SendMailSub(StrMailTo.Text, StrMailSub.Text, StrMailBody.Text)

MsgBox("Your Message Has Been Sent" _
, MsgBoxStyle.Information _
, "Message Sent" _
)

Catch( ex as Exception )

MsgBox( ex.GetType().ToString() )
MsgBox( ex.Message )
MsgBox( ex.StackTrace )
MsgBox( ex.ToString() ) ' the best for last...

End Try
End Sub

HTH,
Phill W.
Jun 27 '08 #3
Ben
On 26 Jun, 12:30, "Patrice" <http://www.chez.com/scribe/wrote:
And the exact line is ? I assume it would be rather inside "SendMailSub".
The weird thing is that this is AspNetHostingPermission which should likely
be used in ASP.NET application. This is a Windows application ? What are you
using in the System.Web namespace ?

If you are using System.Web.MailMessage this is obsoleted. You may want to
try using System.Net.Mail instead as the comiler should have warned you....

--
Patrice

"Ben" <bjblackm...@hotmail.coma écrit dans le message de groupe de
discussion :
53b857ab-11b7-444d-9b73-dae40bc37...@k37g2000hsf.googlegroups.com...
Hi,
I'm new to VB.Net programming, and am trying to learn VB using the new
Visual Studeio 2008 Express Edition. I've decided just to jump
straight in and try to program a simple mail form with 3 fields, 'to',
'subject' & 'body'. Running through the debugger, most of the code
seems to work, however I keep getting the following security error,
even though I have set the application as a full trusted application.
A first chance exception of type 'System.Security.SecurityException'
occurred in MyApplication.exe
Request for the permission of type
'System.Web.AspNetHostingPermission, System, Version=2.0.0.0,
Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
The code that this happens on is the line below with the Call function
in.
* *Private Sub SendMail_Click(ByVal sender As System.Object, ByVal e
As System.EventArgs) Handles SendMail.Click
* * * *Call SendMailSub(StrMailTo.Text, StrMailSub.Text,
StrMailBody.Text)
* * * *MsgBox("Your Messege Has Been Sent", MsgBoxStyle.Information,
"Messege Sent")
* *End Sub
Can anyone please help with this error?
Many thanks
Ben- Hide quoted text -

- Show quoted text -
Hi Patrice,

Thanks for the reply.

The code that was erroring was the call function line: Call
SendMailSub(StrMailTo.Text, StrMailSub.Text,
StrMailBody.Text)

Strangely the compiler didn't say that System.Web.MailMessage was
obsoleted until I decided to create a new project, and copied the
existing code into it, then it flagged it up, and suggested
System.Net.Mail. I just finished changing it over to use
System.Net.Mail, and it works. Yay! My first VB.NET application :-)

Thanks for the help!

Ben
Jun 27 '08 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Sam | last post by:
I have a desktop VB.Net application I developed locally. I uploaded it to a file server we have and the .Net Framework is installed on the file server. When I try to run the executable from the...
4
by: Steven | last post by:
I just downloaded the June 2005 release and I want to set up basic logging to log problems such as exceptions. I have created a category named Exceptions with the following: <category...
0
by: James B | last post by:
OMA (Outlook Mobile Access) under Exchange is giving me a System.Security.SecurityException error. From what I gather this is a problem with the security level under which the OMA application is...
2
by: MFRASER | last post by:
I am getting a System.Security.SecurityException when I try and laod a dataset from an xml file any ideas on what would cause this? System.Security.SecurityException' occurred in mscorlib.dll ...
1
by: edge | last post by:
hi, here it is my problem. My console app, reads a text file where it grabs username/password. Next, my app creates a .BAT file to trigger the command ftp:\\user:password@ftphomeaddress. ...
0
by: Luis Esteban Valencia | last post by:
Hello I have this error when I submit the page with the following code. I had never see this kind of errors. Thanks private void btnsubmit_Click(object sender, System.EventArgs e) { ...
3
by: steveeisen | last post by:
microsoft.public.dotnet.languages.vb.upgrade isn't getting much traffic, so I'll try here. Ours is a VB6 shop exploring .NET. First I wrote a new application with VB .NET 2003 to create a...
0
by: Lambuz | last post by:
Hi all, I've got this problem. I've to implemente a solution like the example in http://support.microsoft.com/default.aspx?scid=kb;EN-US;313891, but I can't configure correctly the example. ...
4
by: confused1234 | last post by:
I get the error at the bottom of this post when i click on a linkbutton, javascript:__doPostBack('ctl00$Main$btnchangeemail','') The problem is intermitant, sometimes it works and sometimes...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.