Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The strings in this interface are variants on C style strings (char*'s) but COM Interop by default treats strings as BSTRs. You have the marshaller trying to read the wrong kind of string and then free it with the CoTask memory allocator, so it's no surprise you get an access violation. If your strings were [In] parameters you could just adorn them with the appropriate MarshalAs attribute but that won't work with return value parameters. So you need to marshal them as IntPtrs and then manually marshal and free the underlying memory.</p> <p>I would try the following:</p> <pre><code>[Guid("fab51c92-95c3-4468-b317-7de4d7588254"), ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] interface nsICacheEntryInfo { IntPtr clientID { get; } IntPtr deviceID { get; } IntPtr key { get; } int fetchCount { get; } uint lastFetched { get; } uint lastModified { get; } uint expirationTime { get; } uint dataSize { get; } [return: MarshalAs(UnmanagedType.Bool)] bool isStreamBased(); } </code></pre> <p>As Chris mentioned above the PRUint32s are actually 32 bit not 64 bit unsigned integers so I've changed them. Also, I've changed the methods to properties since that captures the meaning of the idl better, since they are all readonly it doesn't actually affect the layout. </p> <p>The strings for clientID and deviceID can be read using Marshal.PtrToStrAnsi as so:</p> <pre><code> nsIMemory memoryManagerInstance = /*maybe get this from somewhere*/; nsICacheEntryInfo cacheEntryInstance = /*definitely get this from somewhere*/; IntPtr pClientID = cacheEntryInstance.clientID; string clientID = Marshal.PtrToStringAnsi(pClientID); NS_Free(pClientID); //or memoryManagerInstance.free(pClientID); </code></pre> <p>Whether you use NS_Free or the memory interface to free the strings depends on how you are using the whole xpcom setup. The key value is an abstract string so its representation depends on where it comes from. It appears though that it can usually be treated as a pointer to an ANSI string like the others. </p> <p>I don't have the setup to try any of this for you and the documentation is, to say the least, somewhat opaque so you may need to do a little tweaking on this.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload