Microsoft.Data.SqlXml.SqlXmlCommand in asp.net 2.0 web application

Hi guys, I met a problem when I use Microsoft.Data.SqlXml.SqlXmlCommand in asp.net 2.0 web application.

The following is the code:

using Microsoft.Data.SqlXml;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
ConnectionStringsSection secConn = (ConnectionStringsSection)ConfigurationManager.GetSection("connectionStrings");
string strConn = secConn.ConnectionStrings["sqlXmlConn"].ToString();
try
{
SqlXmlCommand cmd = new SqlXmlCommand(strConn); <-- error occurs here
}
catch (Exception ex)
{
}
}
}

If <trust level="Full" originUrl="" /> is set in web.config of machine, the code works fine.

if <trust level="Medium" originUrl="" /> is set in web.config of machine, there is an exception as following:

Server Error in '/' Application.


Security Exception

Description:The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.

Exception Details:System.Security.SecurityException: That assembly does not allow partially trusted callers.

Is there somebody met same problem?

[1692 byte] By [XJiang] at [2007-12-24]

SQL Server

Site Classified