I am trying to convert an Object to dynamic type but the conversion is failing with RunTimeBinder exception
<p>I am trying to convert an Object to dynamic type but the conversion is failing with RunTimeBinder exception. I tried using two methods that I came across in Stackoverflow answers.</p>

<p>Code 1:</p>

<pre><code>object objSum;
dynamic dynSum;
objSum = dataTableColumnChart.Compute(String.Format("Count({0})", strColumnName), "");
dynSum = Convert.ChangeType(objSum, objSum.GetType());\
Debug.Writeline(dynSum);
</code></pre>

<p>Code 2:</p>

<pre><code>dynSum=objSum;
Debug.Writeline(dynSum);
</code></pre>

<p>The exception thrown is this:</p>

<pre><code>A first chance exception of type 'Microsoft.CSharp.RuntimeBinder.RuntimeBinderException' occurred in Unknown Module.
</code></pre>

<p>Please note that in both cases exception is thrown when Debug statement is executed.</p>