none
Windows Console Application: Security Exception while trying to access SQL Server RRS feed

  • Question

  • Hi,

     

    I tried to use Console Application in VisualStudio.Net 2005. The code works fine on my local machine but I get an error when I put it on the network: 

     

    Request for the permission of type 'System.Data.SqlClient.SqlClientPermission, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.

     

    The error happens at Conn.Open. 

    I spent all day online looking reading postings but couldn't find solution.

    This is a simplified version of my code.

     

    qry = "select * from customer" 

    cmd = New SqlCommand(qry, Conn)

     

    If Conn.State = ConnectionState.Closed Then

        Conn.Open()

    End If

           

    rdr = cmd.ExecuteReader()

     

    While rdr.Read()

       EMAIL = rdr("email")

       If IsDBNull(EMAIL) = False Then

          SendEmail(EMAIL)

       End If

    End While

     

    rdr.Close()

    Conn.Close()

     

    Thanks,

    Ellen

     

    Monday, June 25, 2007 2:46 PM

All replies

  • You're encountering something that happens with any .NET application that's run from a network share.  Take a look at this post from the .NET Security Blog.
    Monday, June 25, 2007 9:42 PM
  • It is an exception that is related to the trust level when application runs ever the network or from some remote location. By default, .NET restricts some access to the resources for the remote applications. You could adjust it using CASPOL tool that comes with .NET

    Tuesday, June 26, 2007 10:28 AM
    Moderator