Error while declaring Interfaces regarding HRESULT
-
Error : "The type or namespace HRESULT could not be found(are you missing a using directive or an assembly reference)" Code Snippet using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.InteropServices.ComTypes; using System.Text; [ ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid(IIDGuid.EnumIdList), ] internal interface IEnumIDList { [PreserveSig()] HRESULT Next(uint celt, out IntPtr rgelt, out int pceltFetched); [PreserveSig()] HRESULT Skip(uint celt); void Reset(); void Clone([Out, MarshalAs(UnmanagedType.Interface)] out IEnumIDList ppenum); } Please help...
-
Error : "The type or namespace HRESULT could not be found(are you missing a using directive or an assembly reference)" Code Snippet using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Runtime.InteropServices.ComTypes; using System.Text; [ ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid(IIDGuid.EnumIdList), ] internal interface IEnumIDList { [PreserveSig()] HRESULT Next(uint celt, out IntPtr rgelt, out int pceltFetched); [PreserveSig()] HRESULT Skip(uint celt); void Reset(); void Clone([Out, MarshalAs(UnmanagedType.Interface)] out IEnumIDList ppenum); } Please help...
For C#'s COM Interop
HRESULT
will be returned asuint
when using the PreserveSig(true) attribute. Change the method signatures in your interface of the two methods that returnHRESULT
to returnuint
instead and you should be good to go. You can also go a step further and create auint enum
that defines the possible result values:public enum Next_HRESULTs : uint
{
S_OK 0x...,
...
}public enum Skip_HRESULTs : uint
{
S_OK 0x...,
...
}Hold on a second here... Don't you think you might be putting the horse ahead of the cart?