Unity and ComImport

Hi,

I’m trying to use ComImport to import a COM+ Interface into Unity and call methods forth and back.
The declaration is:

[ComImport, Guid("1A00A7BA-C217-11E0-AC90-0024811441FD"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
    internal interface IFTFaceTracker

But for some reason, as soon as I try to ComImport anything, Unity crashes. Anyone has any idea on why, and if Unity is even capable of ComImport? My target deployment environment is only Standalone Windows.

-Roger-

I’m using ComImport in Unity 4.1.0 to query the Saved Games folder on Windows systems and I have not noticed any problems so far.

You can find the code I’m using for this in the Unify Community Wiki:
Windows Saved Game Directory

If that also crashes Unity for you, it would seem likely that the problem depends on something in your environment. I could imagine that Unity’s web player would have trouble because Microsoft has added lots of barriers to calling COM from a browser due to security concerns.

Correction: This only works in the Editor for me. In the standalone player, the first cast (QueryInterface()) from COM object to interface fails, just as it would happen if all COM-specific attributes were simply ignored.