<p>Having a problem trying to create a function, as part of a BizTalk helper class that returns a value of type (Microsoft.XLANGs.BaseTypes.XLANGMessage). The function code is as follows:</p>

<pre><code>public XLANGMessage UpdateXML (XLANGMessage inputFile)
{
   XmlDocument xDoc = new XmlDocument();
   XLANGMessage outputFile;
   xDoc = (System.Xml.XmlDocument) inputFile[0].RetrieveAs(typeof(System.Xml.XmlDocument));

   // Modify xDoc document code here

   outputFile[0].LoadFrom(xDoc.ToString());
   return outputFile;
}
</code></pre>

<p>This code does not build as I receive an error stating "Use of unassigned local variable
'outputFile'. I have tried to initialize the 'outputFile' using the new keyword ( = new ....), but that also results in a build error.</p>

<p>What am I doing wrong?</p>

In the code you have provided, change the line:
```
```
XLANGMessage outputFile;
```
```
to:
```
```
XLANGMessage outputFile = null;
```
```
and change the
```
TypeOf
```
to
```
typeof
```
You might want to take a look at these two blog articles
here
and
here
that both mention some better ways of doing this including passing classes based on your xsd instead of the XLANGMessage, and using a stream instead of the
```
XMLDocument
```
.
After doing a quick once over with this (because I had a bad feeling) I'm not sure if BizTalk will consume the returned
```
XLANGMessage
```
the way you are trying. It fails with an unconstructed error when I try to use it in my test harness. Later tonight when I have some free time I'll see if there is an easy way to use the
```
XLANGMessage
```
directly in orchestration shapes. Add a comment if you manage to get it working before I update.