Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

MVVM WPF service not able to serialize Windows.Form.Menu

$
0
0

I have a WPF MVVM application I'm trying to return a complex data class thru a web service but unable to update the service when I have this complex data class in one of the methods. The data class is for menu-ing and has a Windows.Forms properties.

I tried to tag those Windows.Forms properties but still failing.

        [System.Runtime.Serialization.IgnoreDataMember]
        public virtual System.Windows.Forms.ToolStripMenuItem  MainMenuItem
        {
            get
            {
                if (m_mainmenuitem == null)
                {
                    m_mainmenuitem = new System.Windows.Forms.ToolStripMenuItem { Name = this.Description, Text = this.Description };
                }

                return m_mainmenuitem;
            }
        }

System.InvalidOperationException: An exception was thrown in a call to a WSDL export extension: System.ServiceModel.Description.DataContractSerializerOperationBehavior
 contract: http://tempuri.org/:ILoginWcf ----> System.Runtime.Serialization.InvalidDataContractException: Type 'System.Windows.Forms.Menu' cannot be serialized. Consider marking it with the DataContractAttribute attribute, and marking all of its members you want serialized with the DataMemberAttribute attribute.  If the type is a collection, consider marking it with the CollectionDataContractAttribute.  See the Microsoft .NET Framework documentation for other supported types.
   at System.Runtime.Serialization.DataContract.DataContractCriticalHelper.ThrowInvalidDataContractException(String message, Type type)
   at System.Runtime.Serialization.DataContract.DataContractCriticalHelper.CreateDataContract(Int32 id, RuntimeTypeHandle typeHandle, Type type)
   at System.Runtime.Serialization.DataContract.DataContractCriticalHelper.GetDataContractSkipValidation(Int32 id, RuntimeTypeHandle typeHandle, Type type)
   at System.Runtime.Serialization.ClassDataContract.ClassDataContractCriticalHelper..ctor(Type type)
   at System.Runtime.Serialization.DataContract.DataContractCriticalHelper.CreateDataContract(Int32 id, RuntimeTypeHandle typeHandle, Type type)
   at System.Runtime.Serialization.DataContract.DataContractCriticalHelper.GetDataContractSkipValidation(Int32 id, RuntimeTypeHandle typeHandle, Type type)
   at System.Runtime.Serialization.DataContractSet.GetDataContract(Type clrType)


chuck


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>