Multi-Part message – “use of unconstructed message ” – Error message when you try to build a BizTalk project

  • Sandro Pereira
  • Apr 29, 2009
  • 2 min read

Sometimes, when we try to build or deploya BizTalk solution, we may get the following error message:

Use of Unconstructed Message ‘MessageName’

I get this error when I try to construct a multi-part message for sending an email with a body and an attachment.

📝 One-Minute Brief

When building BizTalk projects with multi-part messages, you may encounter the “Use of Unconstructed Message” error. This typically happens when Visual Studio detects a logic flow where a message might be accessed before it is initialized. To fix this, ensure you instantiate all message parts (Body and Attachments) within a Construct Message shape using a proper assignment order or by initializing them with null or a RawString.

Cause

There is a common issue when we are developing a BizTalk Server project in Visual Studio. And the reason is that Visual Studio is trying to use a message that has not yet been initialized, or it will “think” that, based on your flow, maybe situations that it will not be initialized.

Solution

Check if you have a reference to the message before its initialize, for example:

myMessage.Body(Microsoft.XLANGs.BaseTypes.ContentType) = "text/plain";
myMessage.Body = new …;

Correct syntax:

myMessage.Body = new …;
myMessage.Body(Microsoft.XLANGs.BaseTypes.ContentType) = "text/plain";

My suggestion is, first, initialize both types of the multi-part message, in my case:

myMessage.Body = new Microsoft.XLANGs.CustomFormattersSDK.RawString(“”);
myMessage.Attachment = new System.Xml.XmlDocument();

and then I define other properties of the message:

myMessage(SMTP.Subject) = …;

and magic appends!! Problem solved.

Another Solution

I suggest not to use, but, if you’re positive that your response message will always have a value, you could instantiate the message inside a construct shape, using:

myMessage.Body = null;
myMessage.Attachment = null
Thanks for Buying me a coffe
Author: Sandro Pereira

Sandro Pereira lives in Portugal and works as a consultant at DevScope. In the past years, he has been working on implementing Integration scenarios both on-premises and cloud for various clients, each with different scenarios from a technical point of view, size, and criticality, using Microsoft Azure, Microsoft BizTalk Server and different technologies like AS2, EDI, RosettaNet, SAP, TIBCO etc. He is a regular blogger, international speaker, and technical reviewer of several BizTalk books all focused on Integration. He is also the author of the book “BizTalk Mapping Patterns & Best Practices”. He has been awarded MVP since 2011 for his contributions to the integration community.

3 thoughts on “Multi-Part message – “use of unconstructed message ” – Error message when you try to build a BizTalk project”

  1. Hi Sandro!

    I found this blog post searching for how to et a parameter to null whene consuming a web service that has string a input parameter. I got the hopes up when I read your suggestion about setting “Msg.Parameter1 = null;”, but when I do I get the error message that “The part of message contained a null value at the end of Construct” at runtime. So it does not work for me. Do you know anyway to set the parameter as null and it will be accepted?

    Many thanks in advance!
    Kind Regards
    Martin Bring

Leave a Reply

Your email address will not be published. Required fields are marked *

The Ultimate Cloud
Management Platform for Azure

Supercharge your Azure Cost Saving

Learn More
Turbo360 Widget

Back to Top