The first problem is that you are returning an object
.
As WebService produce definitions (WSDL), how do you expect the definition to be generated without knowing the actual type ?
You should introduce a DTO styled - class (no logic, only data) like :
[Serializable]
public class Post
{
public int PostID {get;set;}
public int ThreadID { get; set; }
public string Subject { get; set; }
public string Body { get; set;}
}
And change your definition to return such class.
The amount of code is quite light.
[Edit] The above solution will solve your problem. However, the exact source of the problem is this one :
When you works in a .cs file, the compiler used is the compiler of the target framework of your project (3.5 here). The compilation occurs at coding time.
When you works in a .asmx file, the compilation will occurs when the asp.net application will be loaded. The compiler used in the compiler of the asp.net runtime, which is, for the .Net 3.5, the compiler for 2.0 runtime. It's because the Framework 3.5 is only a new set of classes, but the CLR is still in V2 (changed with the V4). In this case, even if your project is in 3.5, only the code in .cs files can use 3.5 language features. All code in aspx and asmx files can only use V2 language feature.