Dev with Rhino v7 and v6 Rhinoceros and RhinoScript Type Libraries (COM) in same project

Hello,
I have an ongoing software project that uses COM libraries in Rhino 6.

  • Rhinoceros 6 Type Library
  • RhinoScript Type Library

Ideally, my application could support both Rhino 6 and Rhino 7 COM operations as needed. It seems that the COM libraries for Rhino 7 are named identically which is causing reference problems in my project. Basically, it seems I need to point to one or the other. With Rhino 5 and 6, the library and namespaces allowed for the rhino type libraries to be referenced into the same project.

image

My solution right now is to structure my code referring to COM into two separate helper library projects with my own namespaces - not terribly efficient but it works. Will Rhino 7’s Type Libraries for COM be updated to distinguish themselves from the Rhino 6 ones?

Namespace clashes are unusual but not unheard of in C# development, and I think you should be able to use the extern alias functionality for this. If you have both type libraries in your references, you can show properties of the reference using F4 or right-click > Properties. Then the second line says
[ Aliases ] [ global ]
You can fill in another alias, for example for the v6 type library
[ Aliases ] [ rhinocom6 ]
and for the v7 type library
[ Aliases ] [ rhinocom7 ]
Then in your code, write on the top:

extern alias rhinocom6;
using rhinocom6::<your-namespace-here>;

To force it using the namespace from the v6 typelib.

See also https://docs.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/extern-alias