Create XlangMessage using C# helper (InvalidOperationException error)

Home Page Forums BizTalk 2004 – BizTalk 2010 Create XlangMessage using C# helper (InvalidOperationException error)

Viewing 0 reply threads
  • Author
    Posts
    • #19491

      Hi,

      Iam trying to create a Multipart message which contains a Body and multiple parts.  I receive a email message and use a multipart type message to receive the email.

      Then I send the received MP message to the function CreateMPResMsg.
      By looping through the multipart, I try to access its properties and create a multipart message. The problem I am facing is while I am trying to send this message using a send port, Iam getting the Exception InvalidOperationException.
      Inner exception
      : Microsoft.XLANGs.Core.PartWrapperForUserCode cannot be serialized because it does not have a parameterless constructor.

      Please point me to the right direction or provide some link to sample code to achieve this.

      Thanks,
      GRD

      Code:
      public static XLANGMessage CreateMPResMsg(XLANGMessage MPRecdEmail)
              {
                  int iCount = 0;
                  string sFileName;

                  BTXMessage btxMsg = new BTSInternalMsg(“MPMessage”, Service.RootService.XlangStore.OwningContext);
                  btxMsg.AddPart(“”, “Body”);
             
                  XLANGMessage MpMsg = btxMsg.GetMessageWrapperForUserCode();

                  iCount = MPRecdEmail.Count;

                  for (int iLoop = 0; iLoop < iCount; iLoop++)
                  {
                 
                      object oTemp = MPRecdEmail[iLoop].GetPartProperty(typeof(global::MIME.FileName));

                      if (oTemp != null)
                      {
                          sFileName = oTemp.ToString();
                      }
                      else
                      {
                          sFileName = iLoop.ToString() + “_” + MPRecdEmail[iLoop].Name;
                      }

                      AddXlangMsgPart(MpMsg, MPRecdEmail[iLoop], sFileName);
                  }
                  return MpMsg;
              }

       public static void AddXlangMsgPart(XLANGMessage msg, object part, String partName)
                  {
                      if (msg == null)
                          throw new ArgumentNullException(“message”);
                      if (part == null)
                          throw new ArgumentNullException(“part null”);
                      if (partName == null)
                          throw new ArgumentNullException(“partName”);
                      msg.AddPart(part, partName);
                     }

       Error Details:

      Event Type: Error
      Event Source: XLANG/s
      Event Category: None
      Event ID: 10034
      Date:  4/15/2008
      Time:  6:46:06 PM
      User:  N/A
      Computer: BzDevPc
      Description:
      Uncaught exception (see the ‘inner exception’ below) has suspended an instance of service ‘Multipart.Learn.Multipart(d10bbd8a-c895-065c-c540-8462515c6aa4)’.
      The service instance will remain suspended until administratively resumed or terminated.
      If resumed the instance will continue from its last persisted state and may re-throw the same unexpected exception.
      InstanceId: 8aca4bae-90d5-4acc-a731-50a635802694
      Shape name: send MPMsg Created by code
      ShapeId: 242e0994-7e2f-4838-862e-83bf99d1853f
      Exception thrown from: segment 1, progress 43
      Inner exception: Microsoft.XLANGs.Core.PartWrapperForUserCode cannot be serialized because it does not have a parameterless constructor.
             
      Exception type: InvalidOperationException
      Source: System.Xml
      Target Site: Void CheckSupported()
      The following is a stack trace that identifies the location where the exception occured
         at System.Xml.Serialization.TypeDesc.CheckSupported()
         at System.Xml.Serialization.TypeScope.GetTypeDesc(Type type, MemberInfo source, Boolean directReference, Boolean throwOnError)
         at System.Xml.Serialization.ModelScope.GetTypeModel(Type type, Boolean directReference)
         at System.Xml.Serialization.XmlReflectionImporter.ImportTypeMapping(Type type, XmlRootAttribute root, String defaultNamespace)
         at System.Xml.Serialization.XmlSerializer..ctor(Type type, String defaultNamespace)
         at System.Xml.Serialization.XmlSerializer..ctor(Type type)
         at Microsoft.XLANGs.RuntimeTypes.DotNetTypeMetadata.GetXmlSerializer()
         at Microsoft.XLANGs.RuntimeTypes.XmlHelpers.StreamFromObject(Object o, Type t)
         at Microsoft.XLANGs.Core.Value.GetResetableStream(String& encoding, Boolean wantEncoding)
         at Microsoft.XLANGs.Core.Part.Persist(String& encoding, Boolean wantEncoding)
         at Microsoft.BizTalk.XLANGs.BTXEngine.BTXXlangStore.StagePartData(Part part)
         at Microsoft.BizTalk.XLANGs.BTXEngine.BTXXlangStore.PrepareMessage(XLANGMessage msg, IList promoteProps, IList toPromote)
         at Microsoft.BizTalk.XLANGs.BTXEngine.BTXXlangStore.WriteMessageState(IBTPEPInfoLookup pepLookup, Guid portId, XLANGMessage msg, Segment seg, String opname, String url, IList promoteProps, Boolean track, IList toPromote)
         at Microsoft.BizTalk.XLANGs.BTXEngine.BTXLogicalPortBinding.SendMessage(XLANGMessage msg, XlangStore store, Segment seg, OperationInfo op, IList additionalProps, IList toPromote, Boolean ignoreRoutingFailure)
         at Microsoft.BizTalk.XLANGs.BTXEngine.BTXPortBase.SendMessage(Int32 iOperation, XLANGMessage msg, Correlation[] initCorrelations, Correlation[] followCorrelations, Context cxt, Segment seg, ActivityFlags flags)
         at Multipart.Learn.Multipart.segment1(StopConditions stopOn)
         at Microsoft.XLANGs.Core.SegmentScheduler.RunASegment(Segment s, StopConditions stopCond, Exception& exp)

       

Viewing 0 reply threads
  • The forum ‘BizTalk 2004 – BizTalk 2010’ is closed to new topics and replies.