Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Error while declaring Interfaces regarding HRESULT

Error while declaring Interfaces regarding HRESULT

Scheduled Pinned Locked Moved C#
help
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    giji gangadharan
    wrote on last edited by
    #1

    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...

    B 1 Reply Last reply
    0
    • G giji gangadharan

      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...

      B Offline
      B Offline
      Ben Fair
      wrote on last edited by
      #2

      For C#'s COM Interop HRESULT will be returned as uint when using the PreserveSig(true) attribute. Change the method signatures in your interface of the two methods that return HRESULT to return uint instead and you should be good to go. You can also go a step further and create a uint 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?

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups