Ok, I am calling an interop dll which I have no access to. Here is the pseudo code:
dynamic myVariable = null;
firstInteropMethod(ref myVariable);
secondInteropMethod(myVariable); //Not by ref
The method signatures for the two methods are
firstInteropMethod(ref object someObject);
secondInteropMethod(object someObject);
The expected value is a double array of the definition
double[,]
Now the fun part. My original code gets the wrong results but no error. However, this code:
firstInteropMethod(ref myVariable);
secondInteropMethod((double[,]) myVariable);
Gives the expected results.
Using watches and type of statements I have determined that nothing changes between the two calls so what gives? Why would there be a difference and what would that difference be?
This MSDN article on dynamic explains why casting is needed for COM Interop when operations declare the parameter type as
objectand indicates that using the/link:filelistcompiler option will allow you to define the COM method signatures as dynamic as well.