Saturday, April 17, 2010

Troubleshooting System.Windows.Ria.DomainOperationException – digging into wcf logging

There are might be some setting somewhere to pass on you more detailed error messages when you are developing with wcf ria, but when I was facing the following:

System.Windows.Ria.DomainOperationException: Load operation failed for query 'GetActionPlan'. The server did not provide a meaningful reply; this might be caused by a contract mismatch, a premature session shutdown or an internal server error.

Surely enough, troubleshooting was really easy with wcf logging:

clip_image004

 

<Description>Wrote to the EventLog.</Description>
<AppDomain>f423fb1f-1-129133791278152457</AppDomain>
<ExtendedData xmlns="http://schemas.microsoft.com/2006/08/ServiceModel/DictionaryTraceRecord">
<CategoryID.Name>MessageLogging</CategoryID.Name>
<CategoryID.Value>7</CategoryID.Value>
<InstanceID.Name>FailedToLogMessage</InstanceID.Name>
<InstanceID.Value>3221356549</InstanceID.Value>
<Value0>System.ServiceModel.CommunicationException: There was an error while trying to serialize parameter http://tempuri.org/:GetActionPlanResult. The InnerException message was 'Enum value 'Monthly' is invalid for type ‘…….MilestoneIntervalType' and cannot be serialized. Ensure that the necessary enum values are present and are marked with EnumMemberAttribute attribute if the type has DataContractAttribute attribute.'. Please see InnerException for more details. ---&gt; System.Runtime.Serialization.SerializationException: Enum value 'Monthly' is invalid for type ‘……...MilestoneIntervalType' and cannot be serialized. Ensure that the necessary enum values are present and are marked with EnumMemberAttribute attribute if the type has DataContractAttribute attribute.
at System.Runtime.Serialization.EnumDataContract.WriteEnumValue(XmlWriterDelegator writer, Object value)
 
And as the message above implies, actually one can find that detail in the event log:

clip_image002

Here just to provide sample configuration for wcf logging:

 

<system.serviceModel>
<diagnostics>
<messageLogging logEntireMessage="true" logMalformedMessages="true"
logMessagesAtServiceLevel="true" logMessagesAtTransportLevel="true" />
</diagnostics>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true"/>
</system.serviceModel>
<system.diagnostics>
<sources>
<source name="System.ServiceModel" switchValue="Verbose, ActivityTracing">
<listeners>
<add type="System.Diagnostics.DefaultTraceListener" name="Default">
<filter type="" />
</add>
<add type="System.Diagnostics.ConsoleTraceListener" name="console">
<filter type="" />
</add>
<add name="ServiceModelTraceListener">
<filter type="" />
</add>
</listeners>
</source>
<source name="System.ServiceModel.MessageLogging" switchValue="Verbose, ActivityTracing">
<listeners>
<add type="System.Diagnostics.DefaultTraceListener" name="Default">
<filter type="" />
</add>
<add type="System.Diagnostics.ConsoleTraceListener" name="console">
<filter type="" />
</add>
<add name="ServiceModelMessageLoggingListener">
<filter type="" />
</add>
</listeners>
</source>
</sources>
<sharedListeners>
<add initializeData="C:\temp\wcftracesvc.log"
type="System.Diagnostics.XmlWriterTraceListener, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
name="ServiceModelTraceListener" traceOutputOptions="Timestamp">
<filter type="" />
</add>
<add initializeData="C:\temp\wcfmsgsvc.log"
type="System.Diagnostics.XmlWriterTraceListener, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089"
name="ServiceModelMessageLoggingListener" traceOutputOptions="Timestamp">
<filter type="" />
</add>
</sharedListeners>
<trace autoflush="true" />
</system.diagnostics>

It is always nice when you are given a hint in the error message about what to correct, my case was leading to http://msdn.microsoft.com/en-us/library/system.runtime.serialization.enummemberattribute.aspx

Simple as:

[DataContract]
public enum MilestoneIntervalType
{
[EnumMember]
Monthly = 1,
...

to make my test working:

clip_image006

There are few things I don’t like about this RIA stack default settings and behavior, but ok, fair enough and still quite friendly in troubleshooting.

No comments: