Hello Praveen,
From your description, you're going to use the "AppDomain.AssemblyResolve"
event to capture any potential .NET CAS SecurityException in your ASP.net
web application, but found it not work, correct?
As for the "AppDomain.AssemblyResolve" event, it is designed for capturing
the failure of loading a certain assembly in a certain .net AppDomain, for
example, if the runtime can not find a certain assembly required by the
appdomain(or version mismatch...), it will raise this event and call your
handler if you have registered. However, it does not care about any .NET
CAS specific exception(such as the SecurityException...)
For your scenaro, you're encountering some CAS specific SecurityException
in your ASP.NET application, I think this is because some assembly you used
or your asp.net application's components contains code that demand high
CAS permission which is not granted in partial trust environment. Such
exception would be throwed when a certain method(contains such code) be
executed. Generally, in ASP.NET, you can consider use "Application_Error"
event
#How to: Handle Application-Level Errors
http://msdn2.microsoft.com/en-us/library/24395wz3.aspx
===============
void Application_Error(object sender, EventArgs e)
{
Exception ex = HttpContext.Current.Server.GetLastError();
if (ex is System.Security.SecurityException)
{
Server.Transfer("~/errorinfo.aspx");
}
}
==================
In addition, for ASP.NET CAS issue, it is recommended that we check it at
development time before deployment, and if necessary, we can consider
customize the partial trust security policy or wrapper those privileged
assemblies before deployment. Here are some article describing how to deal
with CAS in asp.net 2.0(include partial trust scenario):
#How To: Use Medium Trust in ASP.NET 2.0
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag2/html
/paght000020.asp
#How To: Use Code Access Security in ASP.NET 2.0
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnpag2/html
/paght000017.asp
Hope this helps.
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.