hi! i am trying to upload asp net web site to goddady ...the site works good locally but than i upload it and try to brows i get :
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: Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
i understand that the application at goddady hosting run at <trust ="medium">level so it's prevents from my dal.cs to execute queries to the data base
how do i configure my classes to run at medium security level (how do i set premissions) i tried to use OdbcPermission class no succses ,i think i just do not know to work with it correctly
the dal.cs code is :
public delegate void errorWorkingOnDbHandler ( Exception e);
public class Dal
{
#region datamembers
public event errorWorkingOnDbHandler errorWorkingOnDb;
OdbcConnection connection;
OdbcCommand command;
#endregion
string cstr;
public Dal( string ConnectionStr)
{
cstr = ConnectionStr;
connection = new OdbcConnection (ConnectionStr);
}
public void OpenConection()
{
try
{
connection.Open();
}
catch ( Exception ex)
{
if (errorWorkingOnDb != null )
errorWorkingOnDb(ex);
return ;
}
}
public void CloseConection()
{
connection.Close();
}
public OdbcDataReader ExecuteReader( string SQLcommand)
{
try
{
command = new OdbcCommand (SQLcommand, connection);
return command.ExecuteReader();
}
catch ( Exception e)
{
onErrorWorkingOnDB(e);
OdbcDataReader o = null ;
return o;
}
}
public void ExecuteNonQuery( string SQLCommand)
{
try
{
command = new OdbcCommand (SQLCommand, connection);
command.ExecuteNonQuery();
}
catch ( Exception e)
{
onErrorWorkingOnDB(e);
}
}
public void onErrorWorkingOnDB( Exception e)
{
File .AppendAllText( @"c:\inetpub\ , e.Message + DateTime .Now.ToLongDateString() + " " + DateTime .Now.ToLongTimeString());
File .AppendAllText( @"c:\inetpub\ , Environment .NewLine);
if (errorWorkingOnDb != null )
{
errorWorkingOnDb(e);
}
}
public object ExecuteScalar( string SQLCommand)
{
try
{
command = new OdbcCommand (SQLCommand, connection);
return command.ExecuteScalar();
}
catch ( Exception e)
{
onErrorWorkingOnDB(e);
return null ;
}
}
public void ExecuteTransaction( params string [] SQLCommandStr)
{
OdbcCommand SQLcommand = connection.CreateCommand();
OdbcTransaction transaction = null ;
try
{
// connection.Open();
transaction = connection.BeginTransaction();
SQLcommand.Transaction = transaction;
foreach ( string CommandStr in SQLCommandStr)
{
SQLcommand.CommandText = CommandStr;
SQLcommand.ExecuteNonQuery();
}
transaction.Commit();
}
catch ( Exception e)
{
if (transaction != null )
transaction.Rollback();
if (errorWorkingOnDb != null )
errorWorkingOnDb(e);
}
finally
{
connection.Close();
}
}
}
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: Request for the permission of type 'System.Security.Permissions.FileIOPermission, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.
i understand that the application at goddady hosting run at <trust ="medium">level so it's prevents from my dal.cs to execute queries to the data base
how do i configure my classes to run at medium security level (how do i set premissions) i tried to use OdbcPermission class no succses ,i think i just do not know to work with it correctly
the dal.cs code is :
public delegate void errorWorkingOnDbHandler ( Exception e);
public class Dal
{
#region datamembers
public event errorWorkingOnDbHandler errorWorkingOnDb;
OdbcConnection connection;
OdbcCommand command;
#endregion
string cstr;
public Dal( string ConnectionStr)
{
cstr = ConnectionStr;
connection = new OdbcConnection (ConnectionStr);
}
public void OpenConection()
{
try
{
connection.Open();
}
catch ( Exception ex)
{
if (errorWorkingOnDb != null )
errorWorkingOnDb(ex);
return ;
}
}
public void CloseConection()
{
connection.Close();
}
public OdbcDataReader ExecuteReader( string SQLcommand)
{
try
{
command = new OdbcCommand (SQLcommand, connection);
return command.ExecuteReader();
}
catch ( Exception e)
{
onErrorWorkingOnDB(e);
OdbcDataReader o = null ;
return o;
}
}
public void ExecuteNonQuery( string SQLCommand)
{
try
{
command = new OdbcCommand (SQLCommand, connection);
command.ExecuteNonQuery();
}
catch ( Exception e)
{
onErrorWorkingOnDB(e);
}
}
public void onErrorWorkingOnDB( Exception e)
{
File .AppendAllText( @"c:\inetpub\ , e.Message + DateTime .Now.ToLongDateString() + " " + DateTime .Now.ToLongTimeString());
File .AppendAllText( @"c:\inetpub\ , Environment .NewLine);
if (errorWorkingOnDb != null )
{
errorWorkingOnDb(e);
}
}
public object ExecuteScalar( string SQLCommand)
{
try
{
command = new OdbcCommand (SQLCommand, connection);
return command.ExecuteScalar();
}
catch ( Exception e)
{
onErrorWorkingOnDB(e);
return null ;
}
}
public void ExecuteTransaction( params string [] SQLCommandStr)
{
OdbcCommand SQLcommand = connection.CreateCommand();
OdbcTransaction transaction = null ;
try
{
// connection.Open();
transaction = connection.BeginTransaction();
SQLcommand.Transaction = transaction;
foreach ( string CommandStr in SQLCommandStr)
{
SQLcommand.CommandText = CommandStr;
SQLcommand.ExecuteNonQuery();
}
transaction.Commit();
}
catch ( Exception e)
{
if (transaction != null )
transaction.Rollback();
if (errorWorkingOnDb != null )
errorWorkingOnDb(e);
}
finally
{
connection.Close();
}
}
}