Compiler errors when .NET Compact Framework project uses an XML Web service that exposes typed DataSet (811588)
The information in this article applies to:
- Microsoft Visual Studio .NET (2003), Enterprise Architect Edition
- Microsoft Visual Studio .NET (2003), Enterprise Developer Edition
- Microsoft Visual Studio .NET (2003), Academic Edition
- Microsoft Visual Studio 2005 Professional Edition
- Microsoft Visual Studio 2005 Standard Edition
- Microsoft Web Services (included with the .NET Framework) 1.0
- Microsoft Web Services (included with the .NET Framework 1.1)
- Microsoft .NET Compact Framework
SYMPTOMSIn Microsoft Visual Studio .NET 2003 or in Microsoft Visual Studio 2005, when you build a .NET
Compact Framework project that uses an XML Web service that exposes a typed DataSet as a WebMethod, several compiler errors occur. For example, you
receive the following error messages: Type 'Serializable'
is not defined. Type 'System.ComponentModel.ToolboxItem' is not
defined. Type 'StrongTypingException' is not
defined. CAUSEWhen you use Add Web Reference in a Smart Device application project to add a Web reference to a
Web service that exposes a typed DataSet, Visual Studio .NET or Visual Studio 2005 binds to the service, and then generates a
proxy class for the Web service. When you try to compile the application,
several compiler errors are generated. The errors occur because Visual Studio
.NET or Visual Studio 2005 inserts many serialization attributes in the proxy file that the .NET
Compact Framework does not support.WORKAROUNDTo work around this problem, use either of the following
methods:
- In your Web service, instead of using Typed DataSet, use the System.Data.DataSet class. You can still handle the data by using a Typed
DataSet on the Web server. Before returning the data, type cast the data
to DataSet in the Web service method, and then return the data to the
client, as in the following sample code:
Visual Basic .NET or Visual Basic 2005 sample code <WebMethod()> _
Public Function GetDataSet() As DataSet
' DataSet1 is a typed DataSet.
Dim objTypedDS As New Dataset1
' Create a DataSet.
Dim objDS As DataSet
objDS = objTypedDS
Return objDS
End Function Visual C# .NET or Visual C# 2005 sample code [WebMethod()]
public DataSet GetDataSet()
{
// DataSet1 is a typed DataSet.
DataSet1 objTypedDS = new DataSet1();
// Create a DataSet.
DataSet objDS;
objDS = (DataSet1)objTypedDS;
return objDS;
} - Manually comment out the serialization attributes in the
generated client proxy class. This allows the .NET Compact Framework project to
gain access to the DataSet in a typed manner. However, every time the Web reference is
updated, you must modify all the affected changes because Visual Studio .NET
overwrites the proxy class.
STATUS This
behavior is by design.REFERENCES
For more information, click the following article number to view the article in the Microsoft Knowledge Base:
313486
Roadmap for Visual Database Tools and typed DataSets
Modification Type: | Major | Last Reviewed: | 2/28/2006 |
---|
Keywords: | kbvs2005applies kbvs2005swept kbcode kbNameSpace kbClient kbprb kberrmsg KB811588 kbAudDeveloper |
---|
|