Asked By stchen
02-Mar-08 10:42 PM

Hi coconet,
Regarding on the "Type not serializable" exception you encountered, it is a
typical error in WCF service when you use base class/interface with derived
classes actually send in WCF service method.
For your case, the problem here is that you only declare the Interface type
in your WCF method( the IPrincipal type which is not a DataContract).
However, WCF service will only expose metadata for types that is decorated
with "DataContract" attribute or any type that is declared as "KnowType".
I saw the you've add "KnowTypeAttribute" in the "TestPrincipal" class, this
is not the correct means of using "KnownTypeAttribute".
interface) or on a DataContract type which has member of the base
type/interface. See the following reference:
http://msdn2.microsoft.com/en-us/library/ms730167.aspx
To address the problem in your case, since you haven't use a base class,
you can add the known type declaration at service contract level. e.g.
=========
[ServiceContract]
[ServiceKnownType(typeof(TestPrincipal ))]
public interface IYourServiceInterface
....
==============
the following article include all the three means that can be used for
apply "KnownType" info for WCF service's custom data contract:
http://footheory.com/blogs/bennie/archive/2007/07/28/handling-data-contract-
object-hierarchies-in-wcf.aspx
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
--------------------
ceiver")]