Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to properly return values from unmanaged interface method?
    primarykey
    data
    text
    <p>I'm in the process of extending GeckoFx (http://geckofx.org) and am having some problems returning array values from unmanaged interfaces provided by XPCom.</p> <p>I've added a great amount of new feature support to GeckoFx using the latest XulRunner 1.9.2.13 build but, I'm getting access violation exceptions when attempting to return arrays from interface methods. Eg:</p> <pre><code>[Guid("43987F7B-0FAA-4019-811E-42BECAC73FC5"), ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] interface mozISpellCheckingEngine { //... void GetDictionaryList([MarshalAs(UnmanagedType.LPArray, ArraySubType=UnmanagedType.LPWStr)]ref string[] dictionaries, out uint count); //... } public static string[] GetAvailableDictionaries() { string[] _dictionaries = null; uint count = 0; //GetSpellChecker() returns a valid mozISpellCheckingEngine object GetSpellChecker().GetDictionaryList(ref _dictionaries, out count); if (count &gt; 0) { if (_dictionaries != null) { return _dictionaries; } } return null; } </code></pre> <p>The problem is when GetDictionaryList returns sometimes it will return a list with a single index and containing the name of one dictionary (I have 2 dictionaries in the location this method searches in) and count returns with the correct value of 2; other times the method will fail and throw an access violation and the value of _dictionaries is string[0] while count remains correct with the value of 2.</p> <p>I guess the biggest part of this question would have to be 'Am I marshaling the method and its parameters correctly in the interface declaration?'.</p> <p>This example code is just that - an example. There are several other XulRunner features I would like to implement in GeckoFx but, they return arrays as well and suffer from the same problem. Until I can get past this issue my work is at a bit of a stand-still.</p> <p>Thanks for any and all help you can provide.</p> <p>-Scott</p>
    singulars
    1. This table or related slice is empty.
    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. 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