Hello guys,
i am currently examining the VDS API and wrote some basic code for sw providers. That worked fine. Now i want to change to Hardware Providers. Therefore i used an Xyratex HW Provider. From Diskraid i can get all relevant Information.
Now from c# programmaticly everything is working fine, till i come to the IVdsLun interface.
Here is some Code to visualize it better:
[ComImport, Guid( "D99BDAAE-B13A-4178-9FDB-E27F16B4603E" ), InterfaceType( ComInterfaceType.InterfaceIsIUnknown )]internalinterface IVdsHwProvider {void QuerySubsystems( out IEnumVdsObject subs );int Reenumerate();int Refresh(); } [ComImport, Guid( "6FCEE2D3-6D90-4F91-80E2-A5C7CAACA9D8" ), InterfaceType( ComInterfaceType.InterfaceIsIUnknown )]internalinterface IVdsSubsystem {int GetProperties( out VDS_SUB_SYSTEM_PROP subProp );void QueryDrives( out IEnumVdsObject drives );void QueryLuns( out IEnumVdsObject luns );void QueryControllers( out IEnumVdsObject luns ); } [ComImport, Guid( "FF24EFA4-AADE-4B6B-898B-EAA6A20887C7" ), InterfaceType( ComInterfaceType.InterfaceIsIUnknown )]internalinterface IVdsDrive {int GetProperties( out DriveProperties driveProp ); } [ComImport, Guid( "3540A9C7-E60F-4111-A840-8BBA6C2C83D8" ), InterfaceType( ComInterfaceType.InterfaceIsIUnknown )]internalinterface IVdsLun {int GetProperties( out LunProperties LunProps ); }
and the PropertyStructure for the Lun
[StructLayout( LayoutKind.Sequential )]internalstruct LunProperties {public Guid id;publiculong ullSize; [MarshalAs( UnmanagedType.LPWStr )]publicstring friendlyName; [MarshalAs( UnmanagedType.LPWStr )]publicstring identification; [MarshalAs( UnmanagedType.LPWStr )]publicstring unmaskingList;publicuint flags;publicuint status;publicuint health;publicuint transitionState;short rebuildPrio; }
now finally the Code snippet.
IVdsSubsystem subSystem = (IVdsSubsystem)subObj; VDS_SUB_SYSTEM_PROP subProp; textBox1.Text+= "Return:" + subSystem.GetProperties( out subProp ) +Environment.NewLine; textBox1.Text += "Name: " + subProp.friendlyName + " Status: " + ((SUBSYSTEM_STATUS)subProp.status).ToString() + "Health: " + ((Health)subProp.health).ToString() + Environment.NewLine;uint thirdFetched; IEnumVdsObject lunEnum; subSystem.QueryLuns( out lunEnum );while (true) {object lunObj; lunEnum.Next( 1, out lunObj, out thirdFetched );if (thirdFetched == 0) { textBox1.Text += "NO Luns found" + Environment.NewLine;break; } IVdsLun lun = (IVdsLun)lunObj;
At the last parsing from the IVdsEnumObject to the IVdsLun Object, i get an Exception. Its in german but i think its okay to show what i mean
Das COM-Objekt des Typs "System.__ComObject" kann nicht in den Schnittstellentyp "IVdsLun" umgewandelt werden. Dieser Vorgang konnte nicht durchgeführt werden, da der QueryInterface-Aufruf an die COM-Komponente für die Schnittstelle mit der IID"{3540A9C7-E60F-4111-A840-8BBA6C2C83D8}" aufgrund des folgenden Fehlers nicht durchgeführt werden konnte: Schnittstelle nicht unterstützt (Ausnahme von HRESULT: 0x80004002 (E_NOINTERFACE)).
In the Registry i can see IVdsLun as an Interface, and it should work as DiskRaid is using the provider itself.
Anyone has an idea what i have done wrong? i need all this for monitoring RAID.