title: Calling methods on interop objects, VB vs. C#
body: <p>In C# I'm calling a function on an interop class (<strong>Connection</strong>, written in VB6), which itself returns a plain object (<strong>System</strong>). Then there's a function on that object (<strong>InitialiseData</strong>) that I also call (even though the compiler isn't aware of it).</p>
  
  <pre><code>var isInitialised = Connection.System.InitialiseData(path);
  </code></pre>
  
  <p>The problem is, because that System object is returning a mere Object, I get the compile error "cannot resolve symbol". I can see why, but the same thing works fine in VB.NET:</p>
  
  <pre><code>Dim isInitialised As Boolean = Connection.System.InitialiseData(path)
  </code></pre>
  
  <p>Presumably VB.NET is doing something in the background that allows a kind of implicit late-binding, whereas C# does not? Is there any way to get C# to compile in a similarly ignorant way?</p>
  
  <p>In fact in this case I seem to be able to work around it by casting the Object to the explicit interop type first:</p>
  
  <pre><code>var system = (QLO.System)Connection.System;
  var isInitialised = system.InitialiseData(path);
  </code></pre>
  
  <p>But I'm still interested in answers for cases where I <em>won't</em> be able to cast to a type, but still want to call functions on it. Forgive me if this is a dumb question, I'm only just starting to move from VB.NET to C#... thanks!</p>