@rosecodym wrote:
I am trying to automate Rhino 6 via COM:
var t = Type.GetTypeFromProgID("Rhino.Interface"); dynamic com = Activator.CreateInstance(t); // Works, launches Rhino var rhino = (IRhinoInterface)com; // InvalidCastException
I’m able to launch Rhino fine. But I can’t figure out how to use the returned COM object to actually do anything. If I try to cast it to any of the types in the provided .tlb, I get an InvalidCastException: “Unable to cast COM object of type ‘System.__ComObject’ to interface type ‘Rhino.IRhinoInterface’”. If I leave it as dynamic and try to use properties/methods directly (e.g. the ones in samples from Rhino 6 COM Interface and Fail to get IRhinoApplication from COM Object in Rhino 6), I get RuntimeBinderExceptions with messages like "Microsoft.CSharp.RuntimeBinder.RuntimeBinderException: ‘‘System.__ComObject’ does not contain a definition for ‘GetScriptObject’’.
I’ve tried all the combinations of ProgIDs in https://developer.rhino3d.com/api/rhinoscript/introduction/external_access.htm and types in the type library, and I see this no matter which pair I pick. Is there some obvious thing I’m missing?
Posts: 2
Participants: 2