none
UnmanagedType.LPArray and ClassInterfaceType.None RRS feed

  • Question

  • I am having a problem with this piece of code. I can call the GetConnectionRawData method from unmanaged code (Powerbuilder), but when I try to reference the properties of ConnectionData I get errors. But If I get rid of "[ClassInterface(ClassInterfaceType.None)]" I have no problem accessing the properties of ConnectionData. Is there a dll conflict? Are the attributes used properly? Any help will be greatly appreciated.

        [ComVisible(true)]
        [ClassInterface(ClassInterfaceType.None)]
        [Guid("1B09A9E8-480F-4b4b-95F5-2CD6586B44A7")]
        public class DBConfigProxyFacade : IDBConfigProxy, IDisposable
        {

            [ComVisible(true)]
            [return: MarshalAs(UnmanagedType.LPArray)]
            public ConnectionData[] GetConnectionRawData(ConnectionType i_connectionType)
            {
                try
                {
                    ConnectionData[] connectionData = _internalWeb.GetConnectionRawData(i_connectionType);
                    return connectionData;
                }
                catch (Exception ex)
                {
                    ErrorMessage = string.Format("Failed to get All Connection data from Configuration Service. Attempting top get from File. {0}", ex.Message);
                    return new ConnectionData[] {};
                }

            }

    Monday, January 4, 2010 7:34 PM

All replies

  • Why are you using LPArray? That usually requires a second parameter that says how many items are in the array.

    In this case, it looks easier to use a self-describing SAFEARRAY.


    Mattias, C# MVP
    Tuesday, February 23, 2010 4:31 PM
    Moderator