Q:

Accessing property from COM object XML Result Set in SSIS Script Task

I am working with an SSIS package that was given. to me. I need to extract XML data from an SSIS variable, but I cannot find a way to do it.
When I hit a breakpoint during runtime in my Script Task, I can hover over the Value property of the variable. This shows me a COM object. When I expand the COM object to view its properties, I see the XML data I need in a property called "xml". How do I get at this property from code? 
var xmldata = Dts.Variables["User::MyVariableName"].Value;
//xmldata is a COM object with no properties available at design time

Here is what I have tried: 

Writing the value out to a file based on examples I have seen online.
This just writes "System.__ComObject" to the file 
Casting the COM object to a MarshalByRefObject. This didn't give me
anymore options for retrieving properties
Setting the COM object to a "dynamic" variable. This gave me a
compile time error
Reflection over the COM object to get its properties
(GetProperties()). The COM object did not support this, so I got back
an 0 length array
Changing the result set from XML to DataSet and filling a DataTable
object. I got back a DataTable with one column and multiple rows of
"System.Byte[]", which is worthless.

None of these things have been successful. 

A:

Ok, It looks like I gave up on using "dynamic" too early. 
Make sure you add a reference to "Microsoft.CSharp", then do something like the code below: 
var data = Dts.Variables["User::MyVariableName"]; //Assuming not null. 
var comObject = ((dynamic)data.value);
var propertyValue = comObject.PropertyYouNeed;  

Make sure the property you are retrieving from the COM object is spelled correctly. A misspelling will not be caught until run time. 

