thanks
我在control_Load加上建立ado.net对象得语句时就报错,不加就不报
public class control : System.Windows.Forms.UserControl
{
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Button button2;
private System.Drawing.Printing.PrintDocument printDocument;
private System.Windows.Forms.PrintPreviewDialog printPreviewDialog;
private System.Data.SqlClient.SqlDataAdapter Adpdata;
private System.Data.SqlClient.SqlCommand Commselect;
private System.Data.SqlClient.SqlConnection Conn;
private DataSet ds_head ;
private DataSet ds_data ;
private DataSet ds_body ;
                  private void control_Load(object sender, System.EventArgs e)
{
         Adpdata= new SqlDataAdapter() ;
Commselect=new SqlCommand();
Conn = new SqlConnection();
ds_head = new DataSet();
ds_data = new DataSet();
ds_body = new DataSet();
}
错误:应用程序试图执行安全策略不允许的操作,此操作需要SecrityException.若要执行该程序所需的权限,请与系统管理员联系,或者使用.net安全策略管理工具

解决方案 »

  1.   

    关键还是看你数据库验证方式是单纯的windows模式还是混合验证模式?
      

  2.   

    不介意的话,把全部代码发到[email protected],帮你看看.
      

  3.   

    where are you using the control? in IE?Control Panel - Administrative Tools - Microsoft.Net Framework Configuration.
      

  4.   

    thanks to  aspcn(飞刀) and all
      

  5.   


    see 
    4. Configure Code Access Permissions
    http://www.gotdotnet.com/team/windowsforms/iesourcing.aspx
      

  6.   

    thank saucer(思归, MS .NET MVP)
      

  7.   

    去掉注释后,在.net 向导中将相应的区域设为完全信任,代码就不会有问题了..但是我靠....有得着这么高吗???不是ADO.Net的问题,似乎是SqlClient与OleDb需要较高的本地权限.
      

  8.   

    在“开始”-》“运行”里输入dcomcnfg.exe,设置 相应应用程序的属性,
    在安全性中自定义级别,在第一和第二中加入“{machinename}\ASPNET 用户”就OK了