Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Visual Studio.NET / General / March 2008

Tip: Looking for answers? Try searching our database.

MailMessageEvent is inaccessible

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
jrl - 10 Mar 2008 07:24 GMT
I am getting the error

'desktop_login_CreateAccount.Createuserwizard1_SendingMail(object,
System.Web.UI.WebControls.MailMessageEventArgs)' is inaccessible due to its
protection level

when I compile code that tries to send an email to a new user (as outlined
here:
ms-help://MS.VSCC.v90/MS.VSIPCC.v90/MS.MSSDK.1033/MS.NETFX30SDK.1033/cpref27/html/T_System_Web_UI_WebControls_CreateUserWizard.htm
)

I have already configured mailsettings through the smtp section of the
web.config file.

How do set the protection level so that the application can send this email?
Steven Cheng - 10 Mar 2008 08:52 GMT
Hi jrl,

The error message you got indicate that the following method is not
accessible(by ASP.NET runtime) due to its protection level:

"desktop_login_CreateAccount.Createuserwizard1_SendingMail"

the protection level here means the  "private", "protected", "public"
access control you used to decorate a method. If you do not specify one, it
is marked as private by default which may cause the ASP.NET runtime unable
to call it. I suggest you try mark it with "protected" or "public" to see
whether it works.

Here are two threads which have mentioned this:

http://www.codeguru.com/forum/archive/index.php/t-242481.html

http://www.velocityreviews.com/forums/t367225-method-is-inaccessible-due-to-
its-protection-level.html

Best regards,

Steven Cheng
Microsoft MSDN Online Support Lead

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we

can improve the support we provide to you. Please feel free to let my
manager know what you think of

the level of service provided. You can send feedback directly to my manager
at: msdnmg@microsoft.com.

This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
>X-Trace-PostClient-IP: 70.67.40.71
>From: "jrl" <jrl@newsgroup.nospam>
>Newsgroups: microsoft.public.vsnet.general
>Subject: MailMessageEvent is inaccessible

>I am getting the error
>
[quoted text clipped - 11 lines]
>
>How do set the protection level so that the application can send this email?
jrl - 10 Mar 2008 15:38 GMT
Thanks very much.
protected void Createuserwizard1_SendingMail(object sender,
MailMessageEventArgs e)
was the proper format.

I was curious how this problem was introduced, since I thought I took it
from ms-help. I took it from within a structure like:
<script runat="server">
void ...
</script>

which suggests that the script context somehow changes this default private
setting to something protected or public.

> Hi jrl,
>
[quoted text clipped - 59 lines]
>>How do set the protection level so that the application can send this
> email?
Steven Cheng - 11 Mar 2008 02:13 GMT
Thanks for your reply.

About the difference between the same function in aspx inline <script>
section, it is a bit more complex. This is related to the ASP.NET page's
compilation model, functions defined in aspx inline tempate are compiled
into the final executing Page class. While function in codebehind are in a
base class(also dynamically generate at runtime). Therefore, if functions
in codebehind class is marked as private, it will not be visible to the
aspx compiled class(executing page class). This is a potential problem when
you use codebehind function as control's event handler(need to make them
protected or public).

Best regards,

Steven Cheng
Microsoft MSDN Online Support Lead

Delighting our customers is our #1 priority. We welcome your comments and
suggestions about how we

can improve the support we provide to you. Please feel free to let my
manager know what you think of

the level of service provided. You can send feedback directly to my manager
at: msdnmg@microsoft.com.

This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
>X-Trace-PostClient-IP: 70.67.40.71
>From: "jrl" <jrl@newsgroup.nospam>
>Newsgroups: microsoft.public.vsnet.general
>References: <Du4Bj.67330$pM4.7030@pd7urf1no>
<au0JDPogIHA.6844@TK2MSFTNGHUB02.phx.gbl>
>In-Reply-To: <au0JDPogIHA.6844@TK2MSFTNGHUB02.phx.gbl>
>Subject: Re: MailMessageEvent is inaccessible

>Thanks very much.
>protected void Createuserwizard1_SendingMail(object sender,
[quoted text clipped - 27 lines]
>>
>> http://www.codeguru.com/forum/archive/index.php/t-242481.html

http://www.velocityreviews.com/forums/t367225-method-is-inaccessible-due-to-
>> its-protection-level.html
>>
[quoted text clipped - 40 lines]
>>>How do set the protection level so that the application can send this
>> email?

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.