2

I'm using this article code to extract the extra large icons. Everything works fine as long as I call its method GetIcon from UI Thread. But if I call from other thread, it throws this error

Unable to cast COM object of type 'System.__ComObject' to interface type 'IImageList'. 
This operation failed because the QueryInterface call on the COM component for the interface with IID 
'{46EB5926-582E-4017-9FDF-E8998DAA0950}' failed due to the following error: 
No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).

I cant use UI thread for extracting thousands of icons. Any solution ?

xmen
  • 1,947
  • 2
  • 25
  • 47
  • 1
    Be sure to make the SHGetImageList call on the worker thread, not the UI thread. And make sure you use Thread and called SetApartmentState() to make it STA. – Hans Passant May 19 '12 at 00:55
  • yes problem was fixed when I used the constructor in same thread I need to use IconIndex. But I still don't get why it reacts like that. – xmen May 19 '12 at 01:47
  • There's no proxy registered for that interface. – Hans Passant May 19 '12 at 01:48

0 Answers0