I am doing some scripting of Adobe InDesign. Their COM implementation is really designed for VB, so it\'s not rigorous about reporting data types, occasionally necessitating
No one has said it this way so I will.
Change
var str = frame.Contents.ToString();
to
string str = frame.Contents.ToString();
but I'm explicitly converting what I want to debug to a string
That's not actually true.
var str = frame.Contents.ToString();
This line is still completely dynamic.
You need to explicitly declare it as a string.
Alternatively, you could static-ize earlier by explicitly declaring frame as TextFrame.
You're being bitten by your use of var here, is my guess.
I'm assuming that Contents is dynamic.
Consider this example:
dynamic d = null;
var s = d.ToString();
s is dynamic not string.
You'll want to cast the object to object before calling ToString, or cast the result of ToString to a string. The point is that at some point, somewhere, you need a cast to get out of the dynamic cycle.
This is how I'd solve it:
string str = ((object)frame.Contents).ToString();
Debug.WriteLine(str);
or
string str = frame.Contents.ToString() as string;
Debug.WriteLine(str);