I have ASP.net website. In App_Code
folder I have class that has extension methods. When running this site from visual studio, everything works. However on my IIS 7 server, i received the following error:
CS1061: 'System.Data.SqlClient.SqlDataReader' does not contain a definition for 'SafeGetString' and no extension method 'SafeGetString' accepting a first argument of type 'System.Data.SqlClient.SqlDataReader' could be found (are you missing a using directive or an assembly reference?)
But the file containing this extention methods is in App_Code folder. Am I missing something important?
ExtentionMethods Class:
public static class ExtentionMethods
{
public static string SafeGetString(this SqlDataReader reader, int colIndex)
{
if (!reader.IsDBNull(colIndex))
return reader.GetString(colIndex);
return "NULL VALUE";
}
public static int SafeGetInt32(this SqlDataReader reader, int colIndex)
{
if (!reader.IsDBNull(colIndex))
return reader.GetInt32(colIndex);
return -1;
}
public static DateTime SafeGetDateTime(this SqlDataReader reader, int colIndex)
{
if (!reader.IsDBNull(colIndex))
{
try
{
}
catch
{
return new DateTime(1800, 1, 1);
}
}
return new DateTime(1800, 1, 1);
}
}