Unable to cast COM object

Hi. I have an error when try to build my project. Error message: unable to cast com object of type 'system.__comobject' to interface type 'solidworks.interop.sldworks.rendermaterial'.

My code is :

RenderMaterial swMaterial = default(RenderMaterial);               

swMaterial = (RenderMaterial)face;

Where face - Face2 of Component.

What am i doing wrong?

Thanks for any help.

SolidworksApi/macros