I have a c# class providing some simple classes and some base class extensions such as this one..
public static Boolean ToBooleanOrDefault(this String s, Boolean Default)
{
return ToBooleanOrDefault((Object)s, Default);
}
public static Boolean ToBooleanOrDefault(this Object o, Boolean Default)
{
Boolean ReturnVal = Default;
try
{
if (o != null)
{
switch (o.ToString().ToLower())
{
case "yes":
case "true":
case "ok":
case "y":
ReturnVal = true;
break;
case "no":
case "false":
case "n":
ReturnVal = false;
break;
default:
ReturnVal = Boolean.Parse(o.ToString());
break;
}
}
}
catch
{
}
return ReturnVal;
}
The class compiles fine and appears to have no issues. I have then referenced the project in a web project and VS2010 intellisense recognises the base class extensions and F12/got to definition jumps to the original source code as expected. However when I compile the web project I get an error for each usage of the base class extension...
Error 28 'string' does not contain a definition for 'ToBooleanOrDefault'
This looks to me like the reference is not used by the compiler so it ignores all my base class extensions. Ideas? The solution was migrated from VS2008 where all worked fine.