Hello Mike,
As for the "Application_Error,Application_Start, Session_End,
Session_Start" methods, they're really of the special case which will
violate the normal best practice rules defined by the built-in code
analysis categories. Actually, it is the ASP.NET runtime which call the
these methods at the proper time.
For these methods, since they're of the particular case and should be
isolated from other normal functions, you can consider the following
options:
1. Since the warning you get is rule "CA1811: Avoid uncalled private
code", you can modify all the functions in the global.asax file as
"protected" , e.g.
protected void Application_Start(...)
this can help suppress the CA1811 warning in thsi particular case.
2. It is a quite reasonable and normal scenario that we may have some
particular methods or code module which violate the common best practice
though they're under our control. The .net 2.0 code analysis provide
warning suppress setting in different granularity. We can enable/disable
certain rules in IDE/project setting or suppress rules for a particular
unit(method, module ....).
For this case, you can use the "SuppressMessageAttribute" to decorate the
functions in the global.asax against the CA1811 rule.
#In Source Suppression Overview
http://msdn2.microsoft.com/en-us/library/ms244717.aspx
e.g.
=====================
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance",
"CA1811")]
void Application_Start(object sender, EventArgs e)
{
................
}
=====================
Hope this helps you.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.