Using COM (interop) types in Dynamo Packages
Last updated
Last updated
What are COM types? -
The standard way to use COM types in C# is to reference and ship the primary interop assemblies (Basically a big collection of APIs) with your package.
An alternative to this is to embed the PIA (Primary interop assemblies) in your managed assembly. This basically only includes the types and members that are actually used by a managed assembly. However this approach has some other issues like type equivalence.
This post describes the issue pretty well:
Dynamo delegates type equivalence to the .NET (dotnet) runtime. An example of this would be that 2 types with the same name and namespace, coming from different assemblies will not be considered equivalent, and Dynamo will give an error when loading the conflicting assemblies. As for interop types, Dynamo will check if the interop types are equivalent using the
Some packages have already been created with embedded interop types (ex CivilConnection). Loading 2 packages with embedded interop assemblies that are not considered equivalent(different versions as defined ) will cause a package load error
. Because of this, we suggest that package authors use dynamic binding (aka late binding) for interop types (solution is also described ).
You can follow this example: